132205258 WorkflowTraining Material

117
IBM Global Services © Copyright IBM Corporation 2003 SAP Business Workflow

description

SAP Workflow training material

Transcript of 132205258 WorkflowTraining Material

  • IBM Global Services

    Copyright IBM Corporation 2003

    SAP Business Workflow

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Course Content

    IntroductionIntroduction Workflow architectureWorkflow architecture Workflow Definition and workflow TemplateWorkflow Definition and workflow Template Workflow steps in detailsWorkflow steps in details TaskTask Business Objects and MethodsBusiness Objects and Methods Container Structure and Container ProgrammingContainer Structure and Container Programming EventsEvents Organisational structure and role resolutionOrganisational structure and role resolution Different types of AgentDifferent types of Agent Workflow and ALEWorkflow and ALE

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    SAP Business Workflow

    SAP Business Workflow is a cross-application tool that makes it possible to integrate business tasks/processes between applications.

    This tool was introduced in R/3 Release 3.0A, and received a substantial facelift in the Enjoy Release, 4.6A,which warranted the new name Workflow Builder.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Need of Workflow

    Hmm ! Time to put in a Hmm ! Time to put in a purchase requisition purchase requisition requestrequest

    11

    33

    I guess Id better send I guess Id better send off some inter-office off some inter-office mail to ask the mail to ask the approvers to approve approvers to approve my requisition.my requisition.

    22 I wonder whoI wonder whoapproves buying approves buying this stuff?this stuff?

    55

    Time drags on . . .Time drags on . . .Meanwhile, in Meanwhile, in Mr. Managers office . . . Mr. Managers office . . . What shall I do next?What shall I do next?

    44

    TIME IS TIME IS MONEY!!!MONEY!!!

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Drawbacks

    Inefficiency.

    Each lacks a way to trace where a task is.

    Who executed or is executing it.

    How much time it required.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Why SAP Workflow

    Workflow ensures that the right work is sent to the right person at the right time in the right sequence with the right information.

    Tool for the automization of business processes Not tied up to any paricular application Operates uniformly accross applications Coordinate all participating tasks Provide users with active support Intelligent routing

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    SAP Business Workflow Architecture

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow ArchitectureOrganisational

    LevelOrganisational

    Level

    Process LevelProcess Level

    Business Object Level

    Business Object Level

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Definition

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Definition

    Workflow definition consists of

    1. Basic Data2. Information about triggering events3. Initial Values4. Containers5. Bindings

    A workflow definition describes the workflow process

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow BuilderThe workflow definition is created in the Workflow Builder and displayed graphically in a network.

    Transaction: SWDD Menu Path: Tools Business Workflow Development Definition tools Workflow Builder.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Definition - StepsA workflow definition is made up of individual modular steps.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Example: Workflow Definition

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    How are Workflows Created in a System

    Within workflow templates, there is a key with the following structure:- A WS task abbreviation for the workflow template- An 8-digit sequence number

    From the structure of the 8-digit number, the system knows whether the template is a standard template delivered by SAP or one created by the customer.

    Customer-defined templates start with the prefix number that was defined in Customizing for the system and client.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Working with Workflow

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Design

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    How workflow gets executed

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Toolbox - SWUSTransaction:Transaction: SWUS. SWUS.Menu Path:Menu Path: Tools -> Business Workflow -> Development -> Runtime Tools-> Start Tools -> Business Workflow -> Development -> Runtime Tools-> Start Workflow (Test Environment).Workflow (Test Environment).

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Steps

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow definition steps

    Workflow definition is made up of individual steps. When creating a step in a workflow definition, the step type must be specified first.

    There are 1. Steps which refer to business activities (activities & user decision)

    2. Steps which are used for internal process control and monitoring (condition, multiple condition, loop, etc)

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Business Activities Steps Activity

    - Can be a single step task with basic business functionality- Can be a multi-step task, which reference to a workflow definition

    User Decision- This provides an opportunity for user interaction with the system.- The response to this decides the selection of the subsequent step.

    Document from template- PA document is created from a document template using variables in the text that are

    filled during program execution.

    Web Activity- Selected container elements are posted using http protocol in XML or SOAP

    message

    Subworkflow- An activity which refers to a workflow rather than a task

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Condition- Branch on the basis of control information from the runtime dependent

    context of the workflow. - An attribute of this object can also be accessed for condition evaluation- Condition evaluation can be done by Field comparison e.g constants , object attribute, system fields

    Multiple condition- In contrast to condition, multiple condition makes it possible for the workflow

    definition to branch in more than two branches.

    - For evaluation of the multiple condition, the value of the basis of comparison is checked at runtime against the comparison values and branched accordingly.

    Internal process control Steps

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Internal process control (contd.)

    WHILE Loop- Steps are processed repeatedly until the conditions contained in the WHILE

    step no longer apply.

    Until Loop- Steps are processed repeatedly until the condition contained in the UNTIL

    step is true.

    Fork- Used for parallel processing branches.- Only a part of the parallel processing branches actually has to run to

    continue the workflow.- Dynamic parallel processing is also possible

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Internal process control (contd.)

    Send mail- Text entered in this step can be used to send a mail to the agent assigned

    Container operations- Used to perform arithmetic operation of value assignment to workflow

    container elements using constants and data in the workflow container .

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Internal process control (contd.)

    Event Creator- An event is created when this step in the workflow is reached.- Other workflows can be started as a reaction to the event created in this

    step. This event must be the triggering event of the relevant workflow tasks and/or templates.

    WAIT for event- Used to stop the whole execution of the workflow until the event is created

    in the system.- Used to wait for events for parallel processing

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Task & Workflow Definition

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    TasksTasks

    Single stepSingle step

    MultistepMultistep

    Standard Task(TS)Standard Task(TS)

    Customer Task(T)Customer Task(T)

    Workflow Template(WS)Workflow Template(WS)

    Workflow Task(WF)Workflow Task(WF)

    Tasks are used to describe a business process

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Similarities and differences of task types

    Customer Task (Type T) Standard Task (Type TS)Workflow Task (Type WF) Workflow Template (Type WS)

    Created by customer Created by SAP and customer

    With validity period Without validity period

    Client-dependent Client-independent

    Must be linked to its possible Must be linked to its possibleagents when it is defined agents when it is defined

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Single and Multistep Tasks

    TasksTasks

    Single stepSingle step

    MultistepMultistep

    References References one object type one object type methodmethod and displays one step and displays one step in the business process in the business process

    Represents the Represents the business business processprocess and is a sequence of and is a sequence of individual tasks and control individual tasks and control steps steps

    Transaction : PFTCTransaction : PFTCMenu Path -> Tools -> Business Workflow -> Development -> Definition tools ->TasksMenu Path -> Tools -> Business Workflow -> Development -> Definition tools ->Tasks

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Single-step tasks

    Single-step tasks describe elementary business activities.

    Single-step tasks operate on an object and refer to one object method each

    Single-step tasks are linked to their possible and permitted agents whose organizational assignments are described in the organizational plan of the enterprise.

    Executable single-step tasks are represented by work items at runtime.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow definition - Multistep tasks A workflow definition has a modular structure consisting of individual

    steps which are linked together.

    The multistep tasks form the business framework for a workflow definition and each references one workflow definition.

    A step in a workflow definition can be an activity.

    An activity always refers to one task (= single-step task or multistep task).

    An activity with one simple triangle refers to a task.

    An activity with three triangles refers to a workflow (subworkflow).

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Task Definition Synchronous and Asynchronous Methods

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Defining a Task

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Settings for Tasks

    Background Confirm end of processingSAPphones

    Task executed in background

    depending on object method

    At runtime user can create attachments

    User explains explicitly that work item is no longer is to be processed

    The workflow dials the telephone number attached to the current customer

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Important Task Attributes

    General

    -Workitems can be executed and forwarded to any SAP User

    General Forwarding Allowed

    -Workitems can be forwarded to any user

    General Forwarding Not Allowed

    -Work items can be forwarded to possible users

    Forwarding not allowed

    -No forwarding allowed

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Work Item Executable single-step tasks are represented by work items at

    runtime.

    Object that represents a task or action in the workflow system at runtime.

    Depending on the work item type, some of these work items are displayed in a user's work list. Other work items, on the other hand, are only used and processed internally.

    The work items are displayed in the integrated inboxes of their selected agents, and can be reserved and executed from there.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Work Items Types

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workitem Types

    W: Dialog work itemRuntime display for a single step task with a user dialog

    D: Missed deadline work itemThe message recipient for the missed deadline is informed.

    F: Workflow work itemRuntime representation of a multi step task

    B: Background work itemRuntime display for a task executed in the background.

    E: Wait step work item:Runtime display for a wait step in the workflow definition.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workitem Text

    Title of workitem in the Business Workplace

    First create the workitem text and position the cursor to include a varible

    Choose the 'Insert variable' icon under the workitem text

    Processes request from &_WI_Object_ID.CreatedBy&

    Example

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Task and its various component in SAP

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Business Object Definition and Implementation

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    SAP Business Workflow has been developed on an object-oriented basis.

    The business object types are identified and described with their object methods in the Business Object Repository(BOR) of the R/3 System.

    Generally one object is created in the system and then processed in a workflow over several steps by various employees.

    Object Types & Workflow

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow deals with object types. Object types are definitions of data. In order to access database data, workflow uses the object type interface.

    Most of the information represented by object types is available in the ABAP/4 Dictionary.

    Objects are created at runtime and are specific instances of defined object types.

    Many object types are delivered by SAP. In addition, the customer can create new object types or extend SAP objects by creating subtypes (child objects). New customer objects or subtypes may be desired if the delivered SAP object does not contain all the characteristics (attributes) or processing options (methods) desired.

    Object Types & Objects

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Object Type - Definition

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Interfaces

    Interfaces are a combination of attributes, methods, and events to be used in common among multiple object types. The purpose of interfaces is to define common functionality in one object type, and to assign that common functionality via an interface to multiple object types across the Business Object Repository. This avoids redundancy of data and functionality definition.

    Each new object type automatically receives the interface IFSAP, the SAP standard interface. IFSAP provides every object type with the following:

    - Method Display- Method ExistenceCheck- Attribute ObjectType

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Key Fields

    Key fields are designed to uniquely identify the object type.

    If the key field has a data type reference of a dictionary table field, the runtime system will look to that table field to retrieve the value of the key when processing the object. When the key field is created, the ABAP/4 program code is generated automatically when the object type is generated.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Attributes

    Attributes provides access to data.

    ABAP Dictionary Field Virtual

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Methods

    Methods incorporate the permitted functions available for an object.Methods have importing and exporting parameters as well as exceptions.

    Methods can be created using :

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Methods

    ImportImportParametersParameters

    METHODMETHOD

    Resu

    lt

    Resu

    lt

    ExportExportParametersParameters

    Exceptio

    Exceptio

    nsns

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Dialog / or background :

    Execution of the method is via a work item in a users integrated inbox or in background by the workflow runtime system. Background methods cannot use messages or exceptions because they cannot be processed by the background system and will result in termination of the program.

    Synchronous / Asynchronous

    Synchronous methods finish executing before handing control back to the calling program. These types of methods can return export parameters, results and exceptions. Asynchronous methods do not return control to the calling program immediately. Once executed, they depend upon events to communicate the results of the method back to the calling program. Asynchronous object methods cannot have results, export parameters or exceptions.

    Methods - Call attributes

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    - Result:

    Synchronous methods may return an export parameter as a result. Aresult can be defined like a dictionary field or an object type .

    - Instance independence:

    Indicates whether an object reference is passed to the method by bindingat the time of execution. Methods that generate and return an objectreference, such as Create, or methods that generate a report listing shouldbe instance independent.

    Methods - Call attributes

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Import /Export Parameters

    The method parameter container contains references to all import, export and result parameters which need to be exchanged back and forth between the calling program (single-step task) and the method. Binding is necessary between the single-step task and the method parameter container to accomplish the data transfer.

    Import parameters are those values which are necessary to execute the method. Import parameters are retrieved from the container CONTAINER using the macro instructions SWC_GET_ELEMENT (single-line) or SWC_GET_TABLE (multiline).

    Export parameter values are passed to the container CONTAINER using the macro instructions SWC_SET_ELEMENT (single-line) or SWC_SET_TABLE (multiline). The result parameter is passed to the CONTAINER element RESULT via the same macro instructions.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    ExceptionsError handling is accomplished through the use of method exceptions (synchronous methods only).

    The workflow definition can branch according to these possible error states and allow for subsequent steps to handle these conditions. Messages and exceptions cannot be used with background methods because they will terminate the program.

    Number of the exception: 0001-1000: exceptions defined for interfaces1001-7999: application-specific exceptions (free for SAP development)8000-8999: exceptions raised by the object manager9000-9999: exceptions defined by the customer (free for customers)

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Exceptions are implemented within a method, between the macro instructions BEGIN_METHOD and END_METHOD.

    EXIT_RETURN Code Variable1 Variable2 Variable3 Variable4.Code = the 4-digit number of the exceptionVariable1 through Variable4 correspond to up to 4 variables which can be derived from the message issued with the exception.

    The following exceptions (for temporary errors) are also available to allow exiting of the program:

    EXIT_OBJECT_NOT_FOUND = object not foundEXIT_CANCELLED = cancelled by the user

    Exceptions

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Events describe the change in the status of an object.Workflow are usually started using events

    Events

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Object Type - Release Status Not accessible at runtime.

    Only in test or internal use, possibly unstable.

    Released for use by the customer.

    The functionality has been replaced. The old functionality is still supported for two releases.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    SubtypeThe subtype inherits all attributes, methods and events of the supertype and is open for new customer-specific attributes, methods and events. The key fields of the supertype and subtype must be identical. This means that any methods and attributes defined on the parent can be executed and accessed on the child object.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Delegation

    This delegation is powerful because it lets you implement your own business logic without modifying any SAP code. As long as the objects are properly delegated, your method will be executed.

    CallingCalling ProgramProgram

    KNA1KNA1

    Method: Method:

    Change passwordChange password

    ZKNA1ZKNA1

    Method: Method:

    Change passwordChange password

    Transaction: Menu Path: SW01Tools Business Workflow - Development - Definition tools - Business Object Builder - Settings - Delegate

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Objects in the workflow

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Business Object Repository (BOR)

    Transaction: Menu Path: SW01Transaction: Menu Path: SW01Tools Tools Tools - Business Workflow Defination tool Busniness Object BuilderTools - Business Workflow Defination tool Busniness Object Builder

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Containers and Bindings- Workflow -

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Types of Containers

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Container

    The workflow container contains workflow-specific system variables and other elements which are defined explicitly.

    As part of the definition of the workflow task, the import and export parameters of the workflow are defined as elements of the workflow container.

    When the workflow is defined in the workflow editor, elements can also be added to the workflow container. These elements are then "local variables" within a workflow definition and can be used, for example, to set up a counting loop.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Task Container

    Each task container already contains the workflow system variable and any additional elements for the method parameters of the referenced object method.

    You have to add additional elements to the task container for additional values are required for variable replacement in the work item text or in the long texts

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Other Types of Containers

    Event parameter containerContains an element which can take the (object) reference to the objectwhose change of status is announced via the event.

    Role parameter containerContains the elements required as input in connection with the roleresolution to be run at runtime.

    Method parameter containerContains elements which will be required as import and export parametersin connection with the method execution.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    What is a Container?

    Field valuesField values

    Multiline listsMultiline lists of field values of field values

    Object Object references references

    Container Definition

    Container Instance

    Application Application DataData

    R/3

    Definition Runtime

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Defining Container Elements

    Element nameElement name Data type Data type DescriptionDescription Multi-lineMulti-line ValueValue referencereference

    Element 1Element 1 Database FieldDatabase Field Description 1Description 1

    Element 2Element 2 Database FieldDatabase Field Description 2Description 2 XX

    Element 3Element 3 Object TypeObject Type Description 3Description 3 XX

    Definition Runtime

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Binding

    A binding is simply the art of of pouring selected container elements from one container into another.

    The binding editor is available when defining: Workflow definitions Triggering events Workflow steps Workflow steps ( Standard roles/ Object methods with parameters)

    The binding editor always references the container to receive the application data. Binding definitions can reference:

    Constants Variables (container elements) System fields

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Container & Dataflow

    TaskTaskContainerContainer

    MethodMethodContainerContainer

    EventEventContainerContainer

    Workflow Workflow ContainerContainer

    triggeringtriggeringeventevent

    triggeringtriggeringeventevent

    syncsynctasktasksyncsynctasktask

    syncsyncmethometho

    dd

    syncsyncmethometho

    dd

    syncsynctasktasksyncsynctasktask

    syncsyncmethometho

    dd

    syncsyncmethometho

    dd

    rolerolerolerole

    asyncasynctasktask

    asyncasynctasktask

    asyncasyncmethometho

    dd

    asyncasyncmethometho

    dd

    44

    terminatingterminatingeventevent

    terminatingterminatingeventevent

    1122

    33

    5566

    77

    88

    99

    10101111

    1212 1313

    14141515

    RoleRoleContainerContainer

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Container Data Structure

    SWC_CONTAINERSWC_CONTAINER

    SWC_CREATE_CONTAINERSWC_CREATE_CONTAINER

    SWC_RELEASE_CONTAINERSWC_RELEASE_CONTAINER

    Declare Container

    Initialize Container

    Release Container

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Writing/Reading Container Elements Defined as Field Values

    SWC_GET_ELEMENTSWC_GET_ELEMENT

    SWC_SET_ELEMENTSWC_SET_ELEMENT

    Variable

    Container Instance

    Variable

    SWC_GET_TABLESWC_GET_TABLE

    SWC_SET_TABLESWC_SET_TABLE

    delete value

    InternalInternalTableTable

    InternalInternalTableTable SWC_DELETE_ELEME

    NTSWC_DELETE_ELEME

    NT

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Writing to Container Elements Defined as Object Types

    Container Instance:

    CONTAINER

    Object Element:MATRLDeclare a variable as an object:

    DATA: MATERIAL TYPE SWC_OBJECT.

    Create an instance of your object in your program:SWC_CREATE_OBJECT MATERIAL MARA MATNR.

    Declare a variable as the key of your object:DATA: MATNR LIKE MARA-MATNR.

    Fill the key with a value:MATNR = 123456.

    Object type from B.O.R.

    Key of object you previously defined

    Transfer value of your object instance to the container element: SWC_SET_ELEMENT CONTAINER MATNR MATERIAL

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Reading Container Elements Defined as Object Types

    Container Instance:

    CONTAINER

    Declare a variable as an object:DATA: MATERIAL TYPE SWC_OBJECT.

    Object Element:MATRL

    Read value of container element to your object: SWC_GET_ELEMENT CONTAINER MATRL MATERIAL.

    Declare a variable as the key of your object:DATA: MATNR LIKE MARA-MATNR.

    Read the object type key into your variable:SWC_GET_OBJECT_KEY MATERIAL MATNR.

    Declare a variable to hold the object type:DATA: OBJTYPE LIKE SWOTOBJID-OBJTYPE.

    Obtain the object type from your object type variable:SWC_GET_OBJECT_TYPE MATERIAL OBJTYPE.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Writing to Container Elements Defined as Multiline Object Types

    Container Instance:

    CONTAINER

    Element:PRItems

    Declare a variable as an internal table object:DATA: REQITEMS TYPE SWC_OBJECT OCCURS 0.

    Create an instance of your object for each table line:SWC_CREATE_OBJECT REQITEM BUS2009 PREQKEY.

    Once the internal table is filled, transfer the internal table to the multiline container element:

    SWC_SET_TABLE CONTAINER PRItems REQITEMS.

    Since this internal table has no header, declare a work area: DATA: REQITEM TYPE SWC_OBJECT.

    Declare key fields of the object(e.g. called PREQKEY) and fill them

    (e.g. within a select loop).

    Append the object instance to the internal table:APPEND REQITEM TO REQITEMS.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Reading Container Elements Defined as Multiline Object Types

    Container Instance:

    CONTAINER

    Object Element:PRItems

    Read value of multiline container element into your internal table object:

    SWC_GET_TABLE CONTAINER PRItems REQITEMS.

    Declare your object:DATA: REQITEM TYPE SWC_OBJECT.

    Loop through your internal table object REQITEMS into individual REQITEM entries.

    Perform operations as needed.

    Use this macro to get the keys of each entry:SWC_GET_OBJECT_KEY REQITEMS PREQKEY

    Use this macro to get the object type of each entry:SWC_GET_OBJECT_TYPE REQITEMS OBJTYPE.

    Declare a variable to hold the object type:DATA: OBJTYPE LIKE SWOTOBJID-OBJTYPE.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Events

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    An event describes a possible status change for an object in the SAP System.

    Before an event can be used in a workflow, it must be defined in the Business Object Repository for the object type.

    Events must be triggered explicitly. The application itself can be the triggering agent.

    Event

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Types of Event Creation

    ChangeChange DocumentDocument

    ChangeChange DocumentDocument

    Status Status ManagementManagement

    Status Status ManagementManagement

    MessageMessageControlControl

    MessageMessageControlControl

    SpecificSpecific HR TablesHR Tables

    SpecificSpecific HR TablesHR Tables

    ABAP CodeABAP CodeIn User ExitIn User ExitABAP CodeABAP CodeIn User ExitIn User Exit

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Using Customizing for event triggerMenu Path :Basic menu -> Tools -> Business Workflow -> Development -> Definition tools Menu Path :Basic menu -> Tools -> Business Workflow -> Development -> Definition tools -> Events -> Events

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Event Creation of Change Document

    Changing Changing Master dataMaster dataChanging Changing

    Master dataMaster dataEvent linkage is Event linkage is

    done to connect todone to connect to the workflow/ taskthe workflow/ task

    Event linkage is Event linkage is done to connect todone to connect to the workflow/ taskthe workflow/ task

    Event creation Event creation (SWEC)(SWEC)

    Event creation Event creation (SWEC)(SWEC)

    Change loggedChange logged using using

    change documentschange documents

    Change loggedChange logged using using

    change documentschange documents

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Event Creation of Status Management

    Event linkage is Event linkage is done to connect todone to connect to the workflow/ taskthe workflow/ task

    Event linkage is Event linkage is done to connect todone to connect to the workflow/ taskthe workflow/ task

    Event creation Event creation ((BSVWBSVW ))

    Event creation Event creation ((BSVWBSVW ))

    StatusStatus ManagementManagement

    StatusStatus ManagementManagement

    When user status changes to E002 , event is triggered

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Event Creation of Message Control

    Create Message type and defineCreate Message type and define workflow as transmission mediumworkflow as transmission mediumCreate Message type and defineCreate Message type and define workflow as transmission mediumworkflow as transmission medium

    Create Condition TableCreate Condition TableCreate Condition TableCreate Condition Table

    Create Access SequenceCreate Access SequenceCreate Access SequenceCreate Access Sequence

    Assign Access SequenceAssign Access Sequence to defined message typeto defined message typeAssign Access SequenceAssign Access Sequence to defined message typeto defined message type

    Define Condition RecordsDefine Condition RecordsDefine Condition RecordsDefine Condition Records

    Assign message type To procedureAssign message type To procedureAssign message type To procedureAssign message type To procedure

    Triggering an event using message control occurs with NAST.

    Maintain the processing program RSWEMC01

    with the FORM routine CREATE_EVENT for

    the output type EVEN and transmission

    medium 9.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Using ABAP CodeThis is using done by writing custom code e.g. by using SAP FM like SWE_EVENT_CREATE inside user exits, BADI etc.

    CALL FUNCTION 'SWE_EVENT_CREATE' EXPORTING OBJTYPE = OBJTYPE OBJKEY = OBJKEY EVENT = EVENT CREATOR = APPLICANT START_WITH_DELAY = ' ' IMPORTING EVENT_ID = EVENTID TABLES EVENT_CONTAINER = CONTAINER EXCEPTIONS OBJTYPE_NOT_FOUND = 01.

    IF SY-SUBRC = 0.COMMIT WORK.

    ENDIF.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Event Creators, Receivers and Event Linkage

    PublishedEvents

    Receivers

    EventEventEventEvent

    LinkageLinkageLinkageLinkage

    Creator

    Anybody wantthis event?

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Type Linkage Entry

    Transaction: Transaction: SWE2SWE2Menu Path :Basic menu -> Tools -> Business Workflow -> Menu Path :Basic menu -> Tools -> Business Workflow -> Utilities > Other tools >Event linkage Utilities > Other tools >Event linkage

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Event TraceTransaction: Transaction: SWELSWELMenu Path :Basic menu -> Tools -> Business Workflow -> Development -> Utilities ->Menu Path :Basic menu -> Tools -> Business Workflow -> Development -> Utilities -> Events -> Event Trace. Events -> Event Trace.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Organisational Structure

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Organizational Structure Business Scenario

    An organizational plan in SAP describes the organizational structure of a company.

    The workflow system finds the agents of the individual tasks by evaluating the organizational plan

    The functions to create and maintain organizational plans are part of the Personnel Planning and Development (PD) part of the SAP HR module

    You must connect this organizational structure to the workflow

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Organizational units contain positions, occupied by employees.

    Jobs are abstract descriptions of task assignments.

    Positions can be linked to jobs. They inherit all the tasks assigned to that job.

    Users. A user is an SAP logon user ID. It thus represents a single person.

    Persons. A person is a specific employee created in the HR module.

    Workflow tasks can be assigned to organizational units, positions, jobs or users.

    The workflow system uses organizational structure to route work items to the correct recipients

    Organizational Management

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Create Organisational Plan

    Create root organizational unitCreate root organizational unit

    Additional organizational unitsAdditional organizational units

    Create jobsCreate jobs

    Create positionsCreate positions

    Assign HoldersAssign Holders

    Assign tasksAssign tasks

    Transaction: Menu Path: PPOCWTransaction: Menu Path: PPOCWTools Tools Business Workflow - Development - Environment - Organizational Management - Business Workflow - Development - Environment - Organizational Management - Simple Maintenance Org plan basic data - CreateSimple Maintenance Org plan basic data - Create

    Create Executive BoardCreate Executive Board

    Create Sales region , ProductionCreate Sales region , Production

    Administrator , Sales ManagerAdministrator , Sales Manager

    Sales Manager eastern ZoneSales Manager eastern Zone

    Create Sales OrderCreate Sales Order

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Position: SecretaryPosition: SecretaryPosition: SecretaryPosition: Secretary

    Position: FI administrator 1Position: FI administrator 1Position: FI administrator 1Position: FI administrator 1

    Position: FI administrator 2Position: FI administrator 2Position: FI administrator 2Position: FI administrator 2

    Organizational unit: FI departmentOrganizational unit: FI departmentOrganizational unit: FI departmentOrganizational unit: FI department

    Position: Head of FI depatmentPosition: Head of FI depatmentPosition: Head of FI depatmentPosition: Head of FI depatment

    Job for FI employeeJob for FI employeeJob for FI employeeJob for FI employee

    User 1User 1User 1User 1

    Manager jobManager jobManager jobManager job

    Job for secretaryJob for secretaryJob for secretaryJob for secretary

    User 2User 2User 2User 2

    User 3User 3User 3User 3

    User 2User 2User 2User 2

    Task Task

    Task Task

    Task Task

    Assigment Workflow Task Organizational Objects

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Agent Assignment and Role Resolution

    - Workflow -

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Agent

    Agent is an executor of a work item.

    Agent is responsible for executing a task in a workflow.

    Agent is determined by the system either through organizational chart or directly if user is assigned as agent for a particular task.

    If the agents of the individual workflow steps are determined using the customer-specific organizational chart, your agent assignment in the workflow remains flexible to change.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Types of Agents

    Deadline AgentsDeadline AgentsDeadline AgentsDeadline Agents

    Notification AgentsNotification AgentsNotification AgentsNotification Agents

    Processing AgentsProcessing AgentsProcessing AgentsProcessing Agents

    Selected agentsSelected agentsare those possible are those possible agents who are agents who are elected to execute a elected to execute a task at runtimetask at runtime

    Selected agentsSelected agentsare those possible are those possible agents who are agents who are elected to execute a elected to execute a task at runtimetask at runtime

    Possible agentsPossible agentsare a collection of are a collection of agents who qualify to agents who qualify to execute a work itemexecute a work item

    Possible agentsPossible agentsare a collection of are a collection of agents who qualify to agents who qualify to execute a work itemexecute a work item

    Actual agentActual agent is the is the agent among those agent among those selected agents who selected agents who actually processes the actually processes the work itemwork item

    Actual agentActual agent is the is the agent among those agent among those selected agents who selected agents who actually processes the actually processes the work itemwork item

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Role Resolution

    List of possible agents (executors) of a task(All supervisors in a dept.)

    Selected Agent(s)(Mr. Banning)

    Role Role ResolutionResolution

    (Supervisor of User PBACON)

    Role = Rules

    A role defines rules by which selected agents can be determined at runtime through role resolution. Role resolution restricts the number of possible agents.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Standard Rules

    A rule container is defined for each rule.

    The rule parameters determine which information is required for the rule resolution to be executed at runtime.

    If an error occurs during rule resolution, setting the termination indicator for the rule resolution determines how the workflow will continue:Flag is selected - the workflow assumes an Error status and a notification is sent to the workflow administrator.Indicator is not activated - the workflow forwards this work item to ALL possible agents.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Rule BasicsTransaction : PFAC_INS(Create)Transaction : PFAC_INS(Create)Menu Path: Tools Business Workflow Development Definition tools Rules for Agent Menu Path: Tools Business Workflow Development Definition tools Rules for Agent Assignment Create/Change/Display.Assignment Create/Change/Display.

    Each rule gets a 8 digit generated by the system prefixed with ACRules can be tested using PFTC or by function module RH_GET_ACTORS

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Rule Definition in a Activity Step Type

    Various options to create standard rules :

    1. Responsibility (Pure configuration no ABAP coding) Defined Value ranges are assigned to Agents Data is filled from workflow container at runtime

    1. Evulution paths (Pure configuration no ABAP coding)

    1. Organizational data (Pure configuration no ABAP coding) Jobs , positions

    1. Functions to be executed ABAP Code Function Module

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Rule Definition with Responsibility: Example

    JonesJones SmithSmith

    AnnaAnna

    MichaelMichael

    WilliamWilliamRossRoss

    DavidDavid

    GeorgeGeorgePeterPeter

    Employee Names A-KEmployee Names A-KEmployee Names A-KEmployee Names A-K

    Employee Names L-ZEmployee Names L-ZEmployee Names L-ZEmployee Names L-Z

    Mr. MillerMr. MillerPosition : Administrator Position : Administrator

    HR HR

    Mr. MillerMr. MillerPosition : Administrator Position : Administrator

    HR HRMr. AndrewMr. Andrew

    Position : Administrator Position : Administrator HR HR

    Mr. AndrewMr. AndrewPosition : Administrator Position : Administrator

    HR HR

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Rule Definition with Responsibility: Example

    Container ElementContainer Element Data Type Data Type NameName

    ElementElement UnameUname NameName

    Value From From To Name

    A* K* Employees from A-Z

    L* Z* Employees from L-Z

    Rules Container DefinitionRules Container Definition

    Areas of ResponsibilityAreas of Responsibility

    Mr. AndrewMr. Andrew

    Mr. MillerMr. Miller

    Which Value?Which Value? Which AgentWhich Agent

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Evaluation path as Rule

    Evaluation path describes how to find one or more organizational objects basedOn an initial organizational unitsExample

    Evaluation pathEvaluation path MeaningMeaning

    WF_ORGUNWF_ORGUN Get organization unit for a user id/person idGet organization unit for a user id/person id

    WF_ORGUSWF_ORGUS All users of a organization unit,job, positionAll users of a organization unit,job, position

    US_CHEFUS_CHEF Superiors of a usersSuperiors of a users

    SAP_HOLDSAP_HOLD Holder of a positionHolder of a position

    Transaction : OOAWTransaction : OOAWMenu Path:Menu Path:

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Evaluation path as Rule contd.

    Here are the basic steps:

    1. Determine the evaluation path that needs to be used2. Create a rule setting the type Function to be executed.3. Enter function module RH_GET_STRUCTURE4. Enter the evaluation path determined in step 1 above5. Following rule container needs to be created

    NameName Data type refData type ref DescriptionDescription ExampleExample

    OTYPEOTYPE OBJEC-OTYPEOBJEC-OTYPE Type of organizational management objectType of organizational management object USUS

    OBJIDOBJID OBJEC_REALOOBJEC_REALO ID of organizational management objectID of organizational management object SMITHSMITH

    ORG_AGENTORG_AGENT WFSYST_AGENTWFSYST_AGENT Organizational management objectOrganizational management object USSMITHUSSMITH

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Role Resolution with Function Modules

    Parameter Parameter TypeType

    NameName Data Type RefData Type Ref MeaningMeaning

    TableTable AC_CONTAINERAC_CONTAINER SWCONTSWCONT Incoming rule containerIncoming rule container

    TableTable ACTOR_TABACTOR_TAB SWHACTORSWHACTOR Outgoing list of agents in agent formatOutgoing list of agents in agent format

    ExceptionException NOBODY_FOUNDNOBODY_FOUND Exception indication no agents foundException indication no agents found

    Role resolution with function module should be done only for complex criteria

    Here are the basic steps:1. A function module with the following interface is created

    2. Create a rule setting the type Function to be executed.3. Enter the created function module name4. Create container elements.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Via organizational objects: Role resolution utilizing organizational data analyses

    the assignment of an organizational object (plant, laboratory, MRP controller,

    planner group, shipping point, sales office) to a position or organizational unit.

    Plant Laboratory Sales Office

    Execution of a Role Resolutionvia Organizational Objects

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Tasks: Possible Agents & Default Roles

    UserUser PositionPosition JobJob Org. UnitOrg. Unit PersonPerson

    TASKTASK

    Default roleDefault role

    Possible agentsPossible agents

    BusinessBusiness WorkplaceWorkplace

    The workplace displays thework items for a agent

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    How are Selected Agents Determined With and Without a Default Role?

    Possible Agents

    Task definition withno default role

    Task definition withdefault role

    Triggering Triggering EventEvent

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    How are Selected Agents Determined With a WF Agent?

    All possible agents who qualify to execute task

    Step definition at workflowdefn. level with an agentspecified. This overrides

    default role at task defn. level

    Task definition withno default role

    Task definition withdefault role

    Triggering Triggering EventEvent

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow and ALE

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    ALE error handlingALE error handling

    U s e r a c t io n R / a c t io n3

    E x e c u t e W o r k i t e m

    F i x e r r o r a n d r e p r o c e s s I D o co rF l a g I D o c f o r d e l e t i o n

    E r r o r i n i n b o u n d f u n c t i o n m o d u l e

    A L E t r i g g e r s e r r o r e v e n t

    W o r k i t e m a p p e a r s i n u s e r 's I n b o x

    D i s p l a y I D o c f o r u s e r p r o c e s s i n g( I D o c m e t h o d " I n p u t F o r e g r o u n d " )

    A L E t r i g g e r s e n d e v e n t

    W o r k i t e m c o m p l e t e d

    i n p u t E r r o r O c c u r r e d

    in p u t F i n is h e d

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow and ALE

    Error Notification

    Active Monitoring

    IDOC Processing

    Notification of successful posting

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow and Error Notification

    D e t e r m i n eR e c i p i e n t s

    U s e r c h e c k s i n b o xa n d e x e c u t e s t h e

    w o r k i t e m

    F i x t h e e r r o r

    P u r g e t h e I D o c

    R e s t a r t t h ep r o c e s s

    U s e r / G r o u pg e t s n o t i f i e d

    v i a a w o r k i t e m

    C a n e r r o r b ef i x e d ?

    E n d

    E x c e p t i o nR a i s e d

    Y e s

    N o

    B u s i n e s s U s e r A n a l y s i s

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Active Monitoring

    Active monitoring allows to specify threshold values for the state of the systemFor e.g threshold can be on the number of IDocs in error or the time limit

    Report Program RSEIDOCA can be executed periodically Selection screen takes as input the threshold values and persons to be notified When defined threshold is exceeded Single Step Task TS30200088 is executed

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Setting up Inbound Process via Workflow

    The standard system can be configured to start a WF for an incoming IDoc. Useful when review is essential before posting Custom. SAP does not deliver standard. The settings are: --Create the custom task or WF --Create a new process Code ( WE42) and attach this custom WF/Task. --In the Partner Profile, attach the new Process code

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Notification of Successful Posting

    The ALE/EDI interface can raise events on successful posting of an IDOC. The settings are:

    --Identify the Appl.Obj created by the Idoc. Txn: WE57 --Identify the event that needs to be raised. --Go to BD67, select Process code and populate Object type and Event. --Identify/Create tasks/WF and enable event linkage.

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    ALE error handlingALE error handling

    Necessary Steps: Create new object type in Business Object Repository for IDOC; object

    is child of IDOCAPPL Create new customer task Create event-couplings linking Event inputErrorOccured linked to standard task Event inputFinished to function module

    To support mass processing: Create new object type as child of IDOCPACKET

    Maintain process code to refer the above objects and events

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Business Workflow Customization

    - Workflow -

  • |

    IBM Global Services

    Copyright IBM Corporation 2003

    Workflow Customizing - SWU3

    SAP Business WorkflowCourse ContentSlide 3Need of WorkflowPowerPoint PresentationSlide 6Slide 7Workflow ArchitectureSlide 9Slide 10Workflow BuilderWorkflow Definition - StepsSlide 13How are Workflows Created in a SystemWorking with WorkflowWorkflow DesignSlide 17Workflow Toolbox - SWUSSlide 19Workflow definition stepsBusiness Activities StepsInternal process control StepsInternal process control (contd.)Slide 24Slide 25Slide 26Slide 27Similarities and differences of task typesSingle and Multistep TasksSlide 30Slide 31Task Definition Synchronous and Asynchronous MethodsDefining a TaskSettings for TasksImportant Task AttributesSlide 36Work Items TypesSlide 38Slide 39Task and its various component in SAPSlide 41Slide 42Slide 43Slide 44InterfacesKey FieldsAttributesSlide 48MethodsSlide 50Slide 51Import /Export ParametersExceptionsSlide 54EventsSlide 56SubtypeSlide 58Objects in the workflowSlide 60Slide 61Types of ContainersSlide 63Slide 64Other Types of ContainersWhat is a Container?Defining Container ElementsSlide 68Container & DataflowContainer Data StructureWriting/Reading Container Elements Defined as Field ValuesWriting to Container Elements Defined as Object TypesReading Container Elements Defined as Object TypesWriting to Container Elements Defined as Multiline Object TypesReading Container Elements Defined as Multiline Object TypesSlide 76EventTypes of Event CreationUsing Customizing for event triggerEvent Creation of Change Document Event Creation of Status Management Event Creation of Message Control Using ABAP CodeEvent Creators, Receivers and Event LinkageType Linkage EntryEvent TraceSlide 87Slide 88Slide 89Create Organisational PlanSlide 91Slide 92Slide 93Types of AgentsRole ResolutionStandard RulesRule BasicsRule Definition in a Activity Step TypeRule Definition with Responsibility: Example Slide 100Slide 101Slide 102Role Resolution with Function ModulesSlide 104Tasks: Possible Agents & Default RolesHow are Selected Agents Determined With and Without a Default Role?How are Selected Agents Determined With a WF Agent?Slide 108ALE error handling Workflow and ALEWorkflow and Error NotificationActive MonitoringSlide 113Notification of Successful PostingSlide 115Slide 116Slide 117