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

6766039 Workflow Training Material

Embed Size (px)

Citation preview

Page 1: 6766039 Workflow Training Material

IBM Global Services

© Copyright IBM Corporation 2003

SAP Business Workflow

Page 2: 6766039 Workflow Training Material

|

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

Page 3: 6766039 Workflow Training Material

|

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.

Page 4: 6766039 Workflow Training Material

|

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 I’d better send I guess I’d 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. Manager’s office . . . Mr. Manager’s office . . . ““What shall I do next?”What shall I do next?”

44

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

Page 5: 6766039 Workflow Training Material

|

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.

Page 6: 6766039 Workflow Training Material

|

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

Page 7: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

SAP Business Workflow Architecture

Page 8: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow Architecture

OrganisationalLevel

Process Level

Business Object Level

Page 9: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow Definition

Page 10: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow Definition

Workflow definition consists of

3. Basic Data4. Information about triggering events5. Initial Values6. Containers7. Bindings

A workflow definition describes the workflow process

Page 11: 6766039 Workflow Training Material

|

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.

Page 12: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

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

Page 13: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Example: Workflow Definition

Page 14: 6766039 Workflow Training Material

|

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.

Page 15: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Working with Workflow

Page 16: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow Design

Page 17: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

How workflow gets executed

Page 18: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow Toolbox - SWUS

Transaction: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).

Page 19: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow Steps

Page 20: 6766039 Workflow Training Material

|

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 - Steps which refer to business activities (activities & user decision)

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

Page 21: 6766039 Workflow Training Material

|

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

Page 22: 6766039 Workflow Training Material

|

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

Page 23: 6766039 Workflow Training Material

|

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

Page 24: 6766039 Workflow Training Material

|

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 .

Page 25: 6766039 Workflow Training Material

|

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

Page 26: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Task & Workflow Definition

Page 27: 6766039 Workflow Training Material

|

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

Page 28: 6766039 Workflow Training Material

|

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

Page 29: 6766039 Workflow Training Material

|

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

Page 30: 6766039 Workflow Training Material

|

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.

Page 31: 6766039 Workflow Training Material

|

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).

Page 32: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Task Definition – Synchronous and Asynchronous Methods

Page 33: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Defining a Task

Page 34: 6766039 Workflow Training Material

|

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

Page 35: 6766039 Workflow Training Material

|

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

Page 36: 6766039 Workflow Training Material

|

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.

Page 37: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Work Items Types

Page 38: 6766039 Workflow Training Material

|

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.

Page 39: 6766039 Workflow Training Material

|

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

Page 40: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Task and its various component in SAP

Page 41: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Business Object Definition and Implementation

Page 42: 6766039 Workflow Training Material

|

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

Page 43: 6766039 Workflow Training Material

|

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

Page 44: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Object Type - Definition

Page 45: 6766039 Workflow Training Material

|

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

Page 46: 6766039 Workflow Training Material

|

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.

Page 47: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Attributes

Attributes provides access to data.

ABAP Dictionary Field Virtual

Page 48: 6766039 Workflow Training Material

|

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 :

Page 49: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Methods

ImportImportParametersParameters

METHODMETHOD

Result

Result

ExportExportParametersParameters

Exceptio

Exceptio

nsns

Page 50: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

–Dialog / or background :

Execution of the method is via a work item in a user’s 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

Page 51: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

- Result:

Synchronous methods may return an export parameter as a result. A

result can be defined like a dictionary field or an object type .

- Instance independence:

Indicates whether an object reference is passed to the method by binding

at the time of execution. Methods that generate and return an object

reference, such as Create, or methods that generate a report listing should

be instance independent.

Methods - Call attributes

Page 52: 6766039 Workflow Training Material

|

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.

Page 53: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Exceptions

•Error 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 interfaces•1001-7999: application-specific exceptions (free for SAP development)•8000-8999: exceptions raised by the object manager•9000-9999: exceptions defined by the customer (free for customers)

Page 54: 6766039 Workflow Training Material

|

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 exception•Variable1 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 found–EXIT_CANCELLED = cancelled by the user

Exceptions

Page 55: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

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

Events

Page 56: 6766039 Workflow Training Material

|

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.

Page 57: 6766039 Workflow Training Material

|

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.

Page 58: 6766039 Workflow Training Material

|

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

Page 59: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Objects in the workflow

Page 60: 6766039 Workflow Training Material

|

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

Page 61: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Containers and Bindings

- Workflow -

Page 62: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Types of Containers

Page 63: 6766039 Workflow Training Material

|

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.

Page 64: 6766039 Workflow Training Material

|

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

Page 65: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Other Types of Containers

Event parameter container

Contains an element which can take the (object) reference to the object

whose change of status is announced via the event.

Role parameter container

Contains the elements required as input in connection with the role

resolution to be run at runtime.

Method parameter container

Contains elements which will be required as import and export parameters

in connection with the method execution.

Page 66: 6766039 Workflow Training Material

|

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

Page 67: 6766039 Workflow Training Material

|

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

Page 68: 6766039 Workflow Training Material

|

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

Page 69: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Container & Dataflow

TaskTaskContainerContainer

MethodMethodContainerContainer

EventEventContainerContainer

Workflow Workflow ContainerContainer

triggeringtriggeringeventevent

syncsynctasktask

syncsyncmethometho

dd

syncsynctasktask

syncsyncmethometho

dd

rolerole

asyncasynctasktask

asyncasyncmethometho

dd

44

terminatingterminatingeventevent

1122

33

5566

77

88

99

10101111

1212 1313

14141515

RoleRoleContainerContainer

Page 70: 6766039 Workflow Training Material

|

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

Page 71: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Writing/Reading Container Elements Defined as Field Values

SWC_GET_ELEMENT

SWC_SET_ELEMENT

Variable

Container Instance

Variable

SWC_GET_TABLE

SWC_SET_TABLE

delete value

InternalInternalTableTable

InternalInternalTableTable SWC_DELETE_ELEME

NT

Page 72: 6766039 Workflow Training Material

|

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

Page 73: 6766039 Workflow Training 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.

Page 74: 6766039 Workflow Training Material

|

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.

Page 75: 6766039 Workflow Training Material

|

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.

Page 76: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Events

Page 77: 6766039 Workflow Training Material

|

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

Page 78: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Types of Event Creation

ChangeChange DocumentDocument

Status Status ManagementManagement

MessageMessageControlControl

SpecificSpecific HR TablesHR Tables

ABAP CodeABAP CodeIn User ExitIn User Exit

Page 79: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Using Customizing for event trigger

Menu Path :Basic menu -> Tools -> Business Workflow -> Development -> Definition tools Menu Path :Basic menu -> Tools -> Business Workflow -> Development -> Definition tools -> Events -> Events

Page 80: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Event Creation of Change Document

Changing Changing Master dataMaster data

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

Event creation Event creation (SWEC)(SWEC)

Change loggedChange logged using using

change documentschange documents

Page 81: 6766039 Workflow Training Material

|

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 creation Event creation ((BSVWBSVW ))

StatusStatus ManagementManagement

When user status changes to E002 , event is triggered

Page 82: 6766039 Workflow Training Material

|

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 medium

Create Condition TableCreate Condition Table

Create Access SequenceCreate Access Sequence

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

Define Condition RecordsDefine Condition Records

Assign 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.

Page 83: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Using ABAP Code

This 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.

Page 84: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Event Creators, Receivers and Event Linkage

PublishedEvents

Receivers

EventEvent

LinkageLinkage

Creator

Anybody wantthis event?

Page 85: 6766039 Workflow Training Material

|

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

Page 86: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Event Trace

Transaction: 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.

Page 87: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Organisational Structure

Page 88: 6766039 Workflow Training Material

|

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

Page 89: 6766039 Workflow Training Material

|

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

Page 90: 6766039 Workflow Training Material

|

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

Page 91: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Position: SecretaryPosition: Secretary

Position: FI administrator 1Position: FI administrator 1

Position: FI administrator 2Position: FI administrator 2

Organizational unit: FI departmentOrganizational unit: FI department

Position: Head of FI depatmentPosition: Head of FI depatment

Job for FI employeeJob for FI employee

User 1User 1

Manager jobManager job

Job for secretaryJob for secretary

User 2User 2

User 3User 3

User 2User 2

Task Task

Task Task

Task Task

Assigment Workflow Task Organizational Objects

Page 92: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Agent Assignment and Role Resolution

- Workflow -

Page 93: 6766039 Workflow Training Material

|

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.

Page 94: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Types of Agents

Deadline AgentsDeadline Agents

Notification AgentsNotification Agents

Processing 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

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

Page 95: 6766039 Workflow Training Material

|

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.

Page 96: 6766039 Workflow Training Material

|

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.

Page 97: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Rule Basics

Transaction : 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’

Page 98: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Rule Definition in a Activity Step Type

Various options to create standard rules :

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

Evulution paths (Pure configuration no ABAP coding)

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

6. Functions to be executed – ABAP Code – Function Module

Page 99: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Rule Definition with Responsibility: Example

JonesJones SmithSmith

AnnaAnna

MichaelMichael

WilliamWilliamRossRoss

DavidDavid

GeorgeGeorge

PeterPeter

Employee Names A-KEmployee Names A-K

Employee Names L-ZEmployee Names L-Z

Mr. MillerMr. MillerPosition : Administrator Position : Administrator

HR HR

Mr. AndrewMr. AndrewPosition : Administrator Position : Administrator

HR HR

Page 100: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Rule Definition with Responsibility: Example

NameNameUnameUnameElementElement

NameNameData Type Data Type Container ElementContainer Element

Employees from L-ZZ*L*

Employees from A-ZK*A*

NameFrom ToValue From

Rules Container DefinitionRules Container Definition

Areas of ResponsibilityAreas of Responsibility

Mr. AndrewMr. Andrew

Mr. MillerMr. Miller

Which Value?Which Value? Which AgentWhich Agent

Page 101: 6766039 Workflow Training Material

|

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

Holder of a positionHolder of a positionSAP_HOLDSAP_HOLD

Superiors of a usersSuperiors of a usersUS_CHEFUS_CHEF

All users of a organization unit,job, positionAll users of a organization unit,job, positionWF_ORGUSWF_ORGUS

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

MeaningMeaningEvaluation pathEvaluation path

Transaction : OOAWTransaction : OOAWMenu Path:Menu Path:

Page 102: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Evaluation path as Rule contd.

Here are the basic steps:

2. Determine the evaluation path that needs to be used3. Create a rule setting the type ‘Function to be executed’.4. Enter function module RH_GET_STRUCTURE5. Enter the evaluation path determined in step 1 above6. Following rule container needs to be created

USSMITHUSSMITHOrganizational management objectOrganizational management objectWFSYST_AGENTWFSYST_AGENTORG_AGENTORG_AGENT

SMITHSMITHID of organizational management objectID of organizational management objectOBJEC_REALOOBJEC_REALOOBJIDOBJID

USUSType of organizational management objectType of organizational management objectOBJEC-OTYPEOBJEC-OTYPEOTYPEOTYPE

ExampleExampleDescriptionDescriptionData type refData type refNameName

Page 103: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Role Resolution with Function Modules

Exception indication no agents foundException indication no agents foundNOBODY_FOUNDNOBODY_FOUNDExceptionException

Outgoing list of agents in agent formatOutgoing list of agents in agent formatSWHACTORSWHACTORACTOR_TABACTOR_TABTableTable

Incoming rule containerIncoming rule containerSWCONTSWCONTAC_CONTAINERAC_CONTAINERTableTable

MeaningMeaningData Type RefData Type RefNameNameParameter Parameter TypeType

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

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

1. Create a rule setting the type ‘Function to be executed’.2. Enter the created function module name3. Create container elements.

Page 104: 6766039 Workflow Training Material

|

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

Page 105: 6766039 Workflow Training Material

|

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

Page 106: 6766039 Workflow Training Material

|

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

Page 107: 6766039 Workflow Training Material

|

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

Page 108: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow and ALE

Page 109: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

ALE error handlingALE error handling

User action R/3 action

Execute Workitem

Fix error and reprocess IDocorFlag IDoc for deletion

Error in inbound function module

ALE triggers error event

Workitem appears in user's Inbox

Display IDoc for user processing

(IDoc method "InputForeground")

ALE triggers end event

Workitem completed

input Error Occurred

input Finished

Page 110: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow and ALE

Error Notification

Active Monitoring

IDOC Processing

Notification of successful posting

Page 111: 6766039 Workflow Training Material

|

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

Page 112: 6766039 Workflow Training Material

|

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

Page 113: 6766039 Workflow Training Material

|

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

Page 114: 6766039 Workflow Training Material

|

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.

Page 115: 6766039 Workflow Training Material

|

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

Page 116: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Business Workflow Customization

- Workflow -

Page 117: 6766039 Workflow Training Material

|

IBM Global Services

© Copyright IBM Corporation 2003

Workflow Customizing - SWU3