Sei sulla pagina 1di 145

Developer Guide to SAP Workflow

Developer Guide to SAP Workflow

Presented by Azman Abdul Hamid, Diagonal.

2005 Diagonal Consulting Pte Ltd

Objectives

This overview is intended to provide an understanding of


SAP Business Workflow.

Intended audience - Interested in building Workflow.


Skill Set - ABAP, Business Object

2005 Diagonal Consulting Pte Ltd

Objectives

By the end of the course you will be able to:


Do Workflow Customizing
Identify how to trigger a workflow
Find the SAP standard workflow and enhance it
Create or extend Business Object
Do Workflow development
Do agent assignment via HR Org Plan or Role resolution
Monitor and diagnose Workflow

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

What is a Workflow ?
SAP tool to automate business processes
Send tasks to the next person in the process
Process tasks that do not require intervention automatically
(background task)
Management of process errors / exceptions
Process visibility what is going to happen next? How far is the
processing right now? Who did that?
Monitor deadlines for completion
Collection of performance statistics

It has been available since SAP R/3 Release 3.0

2005 Diagonal Consulting Pte Ltd

Why use workflow ?


The quality of the process is assured by pushing the relevant information together with links to related
transactions directly to the user. Managers don't have the time to search for information so give them what they
need to reach the correct decision.
Cycle time is reduced by pushing the process directly to the users. The users receive notification of a task
immediately and can even be prioritized by the system.
The tasks are performed consistently and diligently by the users. The workflow system pushes all the
necessary information needed to perform a task, including a clear description of what has to be done, how to do
it and the impact this task has on the business process for your company. At any time, the user can check the
list of tasks pending and determine at a glance which are the important tasks, and which tasks can be
completed the next day without any negative impact.
The process instance is transparent. Any user can check at any time how far the process has progressed
and which stage the process has reached. For example the call center can immediately see the status of a
purchase order, an employee requisitioning a purchase would see at a glance if a colleague has been sitting on
it for too long, the ad hoc notes made when approving an engineering change request are visible long after the
request has gone into production.
The process is flexible, allowing it to be changed on the fly without retraining everyone involved. The
description accompanying the change takes care of on-the-fly process improvements.
Deadline handing ensures that users perform the tasks within the time planned. Escalation measures ensure
that the failure to meet a deadline can be corrected by other means.
Intelligent reporting highlights the weaknesses of a process. Often there is a simple cure to such
weaknesses such as reeducating the users involved in the bottleneck or providing additional information
(automatically). The difficulty of a non-automated process is identifying such bottlenecks.

2005 Diagonal Consulting Pte Ltd

Why implement Workflow?

Do your processes drip or do they flow?


Who does the next step?
Where is the process?
Have any deadlines been met?
Is there duplication of effort?
Are there any bottlenecks?

What are the costs associated with the drip?


Delays discounts lost
Duplication of effort different people doing the same task
Lost data

2005 Diagonal Consulting Pte Ltd

Why implement workflow?

Transform processes to flow


Automation of processes
Cost savings, better use of resource

Monitor and control processes


Performance monitoring with reports
where are the bottlenecks

Management of exceptions by error capture


Increasing thru put
Speed of process increased

Leverage Return On Investment in SAP


An existing part of the SAP system that can deliver the advantages

listed above

2005 Diagonal Consulting Pte Ltd

Workflow Return On Investment

Process cost savings


Time per person spent on process reduced

Reductions in process failure


Savings made because of reductions in failure
Costs associated with failure (Legal fees, management time spent fixing

failure)

Reduction in process cycle time


More items can be processed in the same timeframe

Revenue gain from process improvement


Discounts / rebates received because of improved flow

Intangibles
Person available for other tasks
Statistics to provide measurement and then improve address issues
Audit

2005 Diagonal Consulting Pte Ltd

Key questions about workflow

Who Should ~ Determine agent


Do What/To What ~ Action
When ~ Triggering Event
In What Order ~ Designed Process

2005 Diagonal Consulting Pte Ltd

How are workflow triggered?


Publishing Events
Events are created in business object type
The event creation is hard coded in the most SAP transaction
Change Document SWEC (Exp. Material master, Vendor, etc)
Status management BSVW (PP, QM, SM, PM)
Message control NACE (Sales Order, Purchase Order)
Change to HR data SWEHR1, SWEHR2, SWEHR3
Business Transaction Event SWU_EWBTE
Call Function Module SWE_EVENT_CREATE or
SWE_EVENT_CREATE_FOR_UPD_TASK in user exit or BADI
Logistic Information System

Call function SWW_WI_CREATE_SIMPLE in program


Start Workflow Transaction (SWUS)
2005 Diagonal Consulting Pte Ltd

Workflow Terms

2005 Diagonal Consulting Pte Ltd

Workflow Applications
HR Module
Leave application
E-claim

MM Module
PO and PR release strategy
Engineering Change Management

FI Module
Invoice release
Logistic Invoice verification

QM Module
Notification Task processing
Missing Certificate workflow

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Configuring the system


Transaction SWU3 Must be done in each client
Automatic Customizing Does everything except prefix
number
Manual Customizing For doing prefix number and
overwrite automatic customizing
Setting Prefix number is not necessary for QAS and PROD
Different development system box or client should have
different prefix number
Usual problem -> Authorization

2005 Diagonal Consulting Pte Ltd

Workflow Customizing

Manual Customizing

2005 Diagonal Consulting Pte Ltd

Overview of Customizing Activities


Activity

Automatic

Always required?

Default Used

Set active plan version

01

Maintain Prefix Numbers

Configure RFC Destination (WORKFLOW_LOCAL_XXX)

Maintain the Default Workflow Administrator

Classify Decision Task as General

Maintain Standard Domain for Internet

Activate Send to Objects and HR Objects

Maintain Demo and Verification Environment

Schedule Background Job for Missed Dead-lines

Schedule Background Job for Work Items with Errors

Schedule Background Job for Condition Evaluation

Schedule Background Job for Event Queue

Schedule Background Job for Clean-up Report

* If you are creating new workflow in this system / client

2005 Diagonal Consulting Pte Ltd

User WF-BATCH
SY-UNAME

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Agents
Possible Agents : The greatest set of possible person
who are allowed to do the work
Responsible Agents : The person that you want to do
the work
Excluded Agents : The person the you dont want to
do the work, even though they are a possible or
responsible agent
Recipient : The person who receive work item in
their inbox. It is also called as Selected Agents

2005 Diagonal Consulting Pte Ltd

Possible Agents
Mandatory for task
Its client dependent and its not transportable
Rule: if you are not a possible agent of the task, you
cant execute it and if there is no possible agent assigned
to a task, no one can execute the task
General Task = Any one can execute the task. It is set in
the task attribute
Marking task attribute to General Task in Production
can create performance problem and serious security
breach
2005 Diagonal Consulting Pte Ltd

How to set the possible agent?


From the workflow builder : the step definition has a
button to assign possible agent where possible (I.e. for
dialog task)
From the standard task. Transaction PFTC_DIS, menu
Additional Data -> Agent Assignment -> Maintain
In the IMG, in the relevant workflow configuration
section
From the Task section of an organization plan
(PPOM)
From the profile generator (transaction PFCG) in the
workflow section (Only for 4.6C or higher)
2005 Diagonal Consulting Pte Ltd

Set possible agent from Workflow Builder

Click the
agent
assignment
button

Double
Click the
step

2005 Diagonal Consulting Pte Ltd

Set possible agent from Standard Task

2005 Diagonal Consulting Pte Ltd

Maintain agent assignment

Create
Agent
assignment

Dont
forget

2005 Diagonal Consulting Pte Ltd

Set possible agent from IMG

2005 Diagonal Consulting Pte Ltd

Set possible agent from Organization Plan


Click assign
button

2005 Diagonal Consulting Pte Ltd

Set possible agent from PFCG

Click Add
Task

Click the
Workflow
tasks button

2005 Diagonal Consulting Pte Ltd

Responsible Agent
Assign at workflow step level or at task level via the
default agent determination role option in the task
definition
The default role is only used if no responsible agents
have been entered at the workflow step level
Example of the difference between possible and
responsible agents
Possible agents : All managers approve requests from employees
to attend training courses
Responsible agents : Your manager is responsible for approving
requests to attend training courses that have been submitted by
you
2005 Diagonal Consulting Pte Ltd

Responsible and excluded agent in workflow builder

Responsible
Agent

Excluded
Agent

2005 Diagonal Consulting Pte Ltd

Default roles of standard task

2005 Diagonal Consulting Pte Ltd

Agent type
Organization Plan
Transaction PPOC (create), PPOM (change)
Organization units are tied to positions
Positions are tied to user ID
Jobs are tied to positions

Roles
Transaction PFAC
Important roles : supervisor (168), chief position (157)
Responsibility role
Function module role
Use role simulation to test the role

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Creating workflow
Enhance SAP standard workflow
How to find the SAP standard workflow
Find using structure search in PFTC
Where used list on the business object

Use wizard
In workflow builder select menu Wizards -> Workflow Wizards
Explorer

Create from scratch

2005 Diagonal Consulting Pte Ltd

Finding SAP standard workflow template

2005 Diagonal Consulting Pte Ltd

Finding SAP standard WS from the business object


Determine the business object
From its description
From Event Trace (SWEL)

Where used list from SWO1

2005 Diagonal Consulting Pte Ltd

Make use the Standard Workflow


To make use the standard workflow, we need to activate the
workflow by activating the event linkage

Click this to
activate the
linkage

2005 Diagonal Consulting Pte Ltd

Make use the Standard Workflow


Dont forget to do the agent assignment (setting possible
agent). The fastest way is using SWUD

Click this
button

2005 Diagonal Consulting Pte Ltd

Make use the Standard Workflow

Dialog Task

The Dialog Tasks, which are


highlighted in red color
dont have possible agent

2005 Diagonal Consulting Pte Ltd

Workflow objects
Single Step Task Types
TS - Standard Task (Client and Time Independent)
T - Customer Task (Client/Time Dependent, not recommended,
do not use)

Multi Step Task Types


WS - Workflow Template (Client and Time Independent)
WF - Workflow Task (Client/Time Dependent, not recommended,
do not use)

Single Step Task refers to one object and exactly one of its
object methods. Its being used as an activity step in the
workflow builder

2005 Diagonal Consulting Pte Ltd

Standard Task

2005 Diagonal Consulting Pte Ltd

Workflow template

Triggering
event

2005 Diagonal Consulting Pte Ltd

Workflow template

2005 Diagonal Consulting Pte Ltd

Step types in workflow builder


Activity : For executing a task or subworkflow. At runtime, data is
passed from the task or subworkflow to the workflow container on
creation of the matching work item, and vice versa on work item
completion
Web activity : For sending XML document from the workflow to
another system. This XML document can start a workflow in another
system. The Web activity can also wait for feedback from the partner
system.
Document from template : A PC document is created from a document
template using variables in the text which are filled during workflow
execution using the workflow container elements. The workflow container
receives a new container element that contains the document ID.
Condition : To check a condition and route the workflow based on the
result of the condition, either the true or the false path is followed. In the
condition editor you can simulate the results of the condition to make the
testing of complex conditions easier.
Multiple condition : Based on the value of a workflow container
element, one of several branches defined in the workflow definition is
processed. Any value not specially assigned to a branch can be processed
in an other values branch.
Event creator : To raise an event
Wait for event : To make workflow waits for a specific event. The work
item is only completed if the expected event occurs.
2005 Diagonal Consulting Pte Ltd

Step types in workflow builder


Container operation : Used to perform arithmetic operations or value
assignment to workflow container elements using constants and data in the
workflow container
Process control : Can be used to cancel the execution of a work item or
workflow or set a work item to obsolete, so that alternative steps can be
taken in the processing obsolete branch
User decision : To ask question and given a predefined list of answers.
Each predefined answer is a separate branch in the workflow
Loop (Until) : To repeat a sequence of steps until the defined
termination condition occurs
Loop (While) : To repeat a sequence of steps as long as the defined
condition is true
Fork : used for parallel processing
Send mail : To send SAP mail
Undefined : Can be used as placeholders during development (is
ignored at runtime)

2005 Diagonal Consulting Pte Ltd

Activity step
Activity step for calling standard task (TS)

2005 Diagonal Consulting Pte Ltd

Activity step
Activity step for calling sub workflow (WS)

2005 Diagonal Consulting Pte Ltd

Web Activity step


Set the URL where XML document is to be sent

2005 Diagonal Consulting Pte Ltd

Condition step
To check a condition with two outcomes (True and False)

2005 Diagonal Consulting Pte Ltd

Multiple Condition step


Check a container with multiple possibilities

2005 Diagonal Consulting Pte Ltd

Event Creator step


To create an event based on an object type container

2005 Diagonal Consulting Pte Ltd

Wait for Event step


The event refers to an object type container

2005 Diagonal Consulting Pte Ltd

Container operation step

2005 Diagonal Consulting Pte Ltd

Process control step

2005 Diagonal Consulting Pte Ltd

User decision step

2005 Diagonal Consulting Pte Ltd

Loop (Until) step

2005 Diagonal Consulting Pte Ltd

Loop (While) step

2005 Diagonal Consulting Pte Ltd

Fork step
For parallel processing

2005 Diagonal Consulting Pte Ltd

Send mail step


Send to SAP mail or internet mail
It will be a background task -> agent = WF-BATCH

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Business Object
Workflow uses business object as the core of its
programming
Business Object => Object type
Extending object type is a common practice in workflow
development to have new methods, attributes, events or
redefine the original methods
After extending the object type (creating sub type), dont
forget to do delegation so that new methods and attributes can
be called from original super type or new sub type
Delegation: SWO1 -> Settings -> Delegate -> System-wide
Without delegation super type cant access the sub type but
sub type can access super type because of inheritance
2005 Diagonal Consulting Pte Ltd

Business Object

2005 Diagonal Consulting Pte Ltd

Business Object

2005 Diagonal Consulting Pte Ltd

Key fields

2005 Diagonal Consulting Pte Ltd

Database Attributes

The implementation is auto generated


2005 Diagonal Consulting Pte Ltd

Virtual Attributes
Combination of other attributes or constants
Explicit implementation required (self programmed)
Calculation upon attribute access
Buffering in the Business Object Builder

2005 Diagonal Consulting Pte Ltd

Methods
Synchronous : the activity performed by the method must
be complete when the method execution ends, including any
database update. Example: Dialog method to display material,
background method to release an Invoice
Asynchronous : does not continue to the next step until it
receives an acknowledgement that the method has finished
(terminating event). Example: Dialog method to change PO
which should finish only when the PO has been changed

2005 Diagonal Consulting Pte Ltd

Objects in Workflow

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Events
Defined at Object Type
Can be triggering or terminating event
Triggering event for Standard Task or Workflow Template
Terminating event for Standard Task only
Event linkage SWETYPV
In the type linkage table there is :
Check function check whether workflow need to be triggered
Receiver type function routing workflow (routing can be done
also by start condition)
Activation flag workflow will be triggered only when this flag is
active
2005 Diagonal Consulting Pte Ltd

Publishing Events
Events which are hard coded in SAP transaction

2005 Diagonal Consulting Pte Ltd

Publishing Events from Change Document


For transactions which create change document such as: Material, Vendor
and Customer, event can be triggered from the change doc (SWEC)

2005 Diagonal Consulting Pte Ltd

Publishing Events from Status Management


For PP, QM, SM, PM module event can be triggered from status
management (BSVW)
For System
Status

For User
Status

2005 Diagonal Consulting Pte Ltd

Publishing Events from Message Control


For Sales Order, Purchase Order, etc; event can be triggered from
message control (NACE)

Click
Processing
routines
Click
Output type

Click New
entries

2005 Diagonal Consulting Pte Ltd

Publishing Events from Message Control

Save it

2005 Diagonal Consulting Pte Ltd

Publishing Events from Message Control


Create the condition record and specify the object type and event in the
communication

Click
Condition
records

2005 Diagonal Consulting Pte Ltd

Publishing Events from Message Control


Click
Communication

Save it

2005 Diagonal Consulting Pte Ltd

Event Type Linkage Table


Transaction SWETYPV

2005 Diagonal Consulting Pte Ltd

Check function module


To check whether workflow is to be
triggered or not
The import, export and tables parameter
must be like the parameter declaration
bellow
If you dont want to trigger the
workflow just raise the exception
Function SWE_TEMPLATE_CHECK_FB
can be used as the template
FUNCTION ZQM_WF_EVT_CHK_Z1_NOTIF_TYPE.
*"---------------------------------------------------------------------*"*"Local interface:
*" IMPORTING
*" VALUE(OBJTYPE) LIKE SWETYPECOU-OBJTYPE
*" VALUE(OBJKEY) LIKE SWEINSTCOU-OBJKEY
*" VALUE(EVENT) LIKE SWEINSTCOU-EVENT
*" VALUE(GENERIC_RECTYPE) LIKE SWETYPECOU-RECTYPE
*" EXPORTING
*" VALUE(RECTYPE) LIKE SWETYPECOU-RECTYPE
*" TABLES
*"
EVENT_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*"
NO_RECTYPE
*"----------------------------------------------------------------------

INCLUDE <CNTAIN>.
DATA: OBJECT TYPE SWC_OBJECT,
QMSM_OBJ TYPE SWC_OBJECT,
TASKCODE TYPE QMSM-MNCOD,
TASKGROUP TYPE QMSM-MNGRP,
LC_OBJNR TYPE QMEL-OBJNR,
N_TYPE TYPE QMEL-QMART.
*--- get object from container
SWC_GET_ELEMENT EVENT_CONTAINER '_EVT_OBJECT' OBJECT.
* Get the object number and notification type
SELECT SINGLE OBJNR QMART INTO (LC_OBJNR, N_TYPE)
FROM QMEL WHERE QMNUM = OBJKEY(12).
IF SY-SUBRC <> 0.
* Dont trigger workflow if there is no notification type
RAISE NO_RECTYPE.
ENDIF.
* Trigger workflow only for Z1 notification type
IF N_TYPE NE 'Z1'.
RAISE NO_RECTYPE.
ENDIF.

2005 Diagonal Consulting Pte Ltd

Receiver type function module


To route which workflow to be triggered
The import, export and tables parameter
must be like the parameter declaration
bellow
Put the workflow to be triggered into
RECTYPE export parameter
Function SWE_TEMPLATE_RECTYPE_FB
can be used as the template
FUNCTION Z_WF_QM_RECEIVER_TASK_CODE_Z1.
*"---------------------------------------------------------------------*"*"Local interface:
*" IMPORTING
*" VALUE(OBJTYPE) LIKE SWETYPECOU-OBJTYPE
*" VALUE(OBJKEY) LIKE SWEINSTCOU-OBJKEY
*" VALUE(EVENT) LIKE SWEINSTCOU-EVENT
*" VALUE(GENERIC_RECTYPE) LIKE SWETYPECOU-RECTYPE
*" EXPORTING
*" VALUE(RECTYPE) LIKE SWETYPECOU-RECTYPE
*" TABLES
*"
EVENT_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*"
NO_RECTYPE
*"----------------------------------------------------------------------

INCLUDE <CNTAIN>.
DATA: OBJECT TYPE SWC_OBJECT,
TASKCODE TYPE QMSM-MNCOD.
*--- get object from container
SWC_GET_ELEMENT EVENT_CONTAINER '_EVT_OBJECT'
OBJECT.
* Get Task code
CALL FUNCTION 'SWO_PROPERTY_GET'
EXPORTING
OBJECT
= OBJECT
ATTRIBUTE
= 'TaskCode'
CHANGING
VALUE
= TASKCODE
EXCEPTIONS
ERROR_CREATE = 1
ERROR_INVOKE = 2
ERROR_CONTAINER = 3
OTHERS
= 4.
CASE TASKCODE.
WHEN '0070'. " Request Interim Report (CS)
* Update Notification User Status to IRIS
RECTYPE = 'WS99000040'.
WHEN '0060'. " Request Final Report (CS)
* Update Notification User Status to FRIS
RECTYPE = 'WS99000039'.
WHEN '0130'. " Send Report to QP for Approval
* Update Notification User Status to QPCL
RECTYPE = 'WS99000036'.
ENDCASE.

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Agent assignment
Direct assignment to Organization Plan
Role resolution for responsible agent
Responsibility role
Function module role
Binding from workflow container to role container

Expression to a workflow container


The container refers to WFSYST-AGENT field
Usually populated from previous step
Special container : _WF_Initiator (Workflow Initiator)
Excluded agent can only use container
2005 Diagonal Consulting Pte Ltd

Responsibility Role

Click
Click
Responsibilities
Container

2005 Diagonal Consulting Pte Ltd

Responsibility Role

2005 Diagonal Consulting Pte Ltd

Responsibility Role

2005 Diagonal Consulting Pte Ltd

Responsibility Role

2005 Diagonal Consulting Pte Ltd

Function Module Role

2005 Diagonal Consulting Pte Ltd

Function Module Role


The import, export and tables parameter
must be like the parameter declaration
bellow
In the function populate ACTOR_TAB
table for the agent
If there is no agent found then raise the
exception
FUNCTION Z_WF_FI_GET_FIRST_CC_APPROVAL.
*"---------------------------------------------------------------------*"*"Local interface:
*"
TABLES
*"
AC_CONTAINER STRUCTURE SWCONT
*"
ACTOR_TAB STRUCTURE SWHACTOR
*"
EXCEPTIONS
*"
NOBODY_FOUND
*"---------------------------------------------------------------------* Container macros
INCLUDE <CNTAIN>.
DATA: LC_KOKRS LIKE TKA01-KOKRS,
LC_KOSTL LIKE CSKS-KOSTL,
LC_BUKRS LIKE ANLA-BUKRS,
LC_ANLN1 LIKE ANLA-ANLN1,
LC_ANLN2 LIKE ANLA-ANLN2,
LC_AUFNR LIKE AUFK-AUFNR.

REFRESH ACTOR_TAB.
* Retrieve values from the role container
SWC_GET_ELEMENT AC_CONTAINER 'ControllingArea' LC_KOKRS.
SWC_GET_ELEMENT AC_CONTAINER 'CostCentre' LC_KOSTL.
SWC_GET_ELEMENT AC_CONTAINER 'Order' LC_AUFNR.
IF NOT LC_AUFNR IS INITIAL.
" Internal Order Object
* Read table ZWF_ORDER_BHL and determine the agent
SELECT SINGLE * FROM ZWF_ORDER_BHL WHERE AUFNR =
LC_AUFNR
AND INIT_CONTACT = 'X'.
IF SY-SUBRC EQ 0.
ACTOR_TAB-OTYPE = 'US'.
ACTOR_TAB-OBJID = ZWF_ORDER_BHL-UNAME.
APPEND ACTOR_TAB.
ENDIF.
ELSE.
" Cost Centre Object
* Read table ZWF_CENTRE_BHL and determine the agent
SELECT SINGLE * FROM ZWF_CENTRE_BHL
WHERE KOKRS = LC_KOKRS AND KOSTL = LC_KOSTL AND
INIT_CONTACT = 'X'.
IF SY-SUBRC EQ 0.
ACTOR_TAB-OTYPE = 'US'.
ACTOR_TAB-OBJID = ZWF_CENTRE_BHL-UNAME.
APPEND ACTOR_TAB.
ENDIF.
ENDIF.
* Final check to make sure an agent is returned
IF ACTOR_TAB[] IS INITIAL.
RAISE NOBODY_FOUND.
ENDIF.

2005 Diagonal Consulting Pte Ltd

How to use Role in Workflow

2005 Diagonal Consulting Pte Ltd

Agent assignment through expression

2005 Diagonal Consulting Pte Ltd

Agent assignment through expression

2005 Diagonal Consulting Pte Ltd

Agent assignment through expression

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Workflow development
Get the requirement by asking the key questions of workflow
If possible try to create a flow chart of the requirement
Make sure Event trace is active in the development box (SWELS)
Do the transaction
Check the event trace (SWEL)
If there is no event triggered by SAP
Is there change document created? -> SWEC
Is there system status or user status created? -> BSVW
Message control -> NACE
HR ???
Business transaction event
User exit or BADI

Write down the business object


2005 Diagonal Consulting Pte Ltd

Workflow development
Where used list from the business object to get the SAP standard
workflow template
If the SAP standard workflow template has been found, copy and
modify the copy otherwise create from scratch
Check whether the methods and attribute of the object type enough.
Extend it if not enough by creating sub type
After creating sub type, do delegation
Create standard task to make use the new methods of the object type
Modify the workflow definition to fit the requirement
Create role if necessary
Do the agent assignment accordingly (responsible, possible and
excluded agent)
Generate the workflow
Maintain the type linkage table (workflow activation, check function,
receiver type function) SWETYPV
2005 Diagonal Consulting Pte Ltd

Workflow scenario
Vendors Master records have multiple views to allow cooperative maintenance between functional groups.
Finance will not be responsible for the initial creation of the
master record but will be responsible for the maintenance of the
FI view.
To ensure timely updates of this information a group of Finance
clerks are to be notified whenever a Vendor master record is
created

2005 Diagonal Consulting Pte Ltd

Getting the requirement


Who Should ~ Determine agent
Do What/To What ~ Action
When ~ Triggering Event
In What Order ~ Designed Process
Step

When

Who should

Do what

A new vendor Finance clerks determine Maintain the FI view of the Vendor through
created
by Purchasing Org
transaction FK01

After step 1
complete

Workflow started
due to
Vendor created

Receive notification that FI View has been


maintained and being able to display the vendor

The vendor creator

Finance to
maintain
Vendor FI
view

Notify
creator that
FI view has
been
maintained

2005 Diagonal Consulting Pte Ltd

Workflow
completed

Find the triggering event


Make sure the event trace is on (SWELS)

Do the transaction (eg. MK01)

2005 Diagonal Consulting Pte Ltd

Find the triggering event


Check the event trace (SWEL)

2005 Diagonal Consulting Pte Ltd

Find the triggering event

Since there is no event triggered by the transaction, try to trigger an event


from change document (For vendor creation there will be change document
created)

2005 Diagonal Consulting Pte Ltd

Find the triggering event


Determine the object type and event that we want to trigger

There is no
Created
event

2005 Diagonal Consulting Pte Ltd

Find the triggering event


Create a sub type of object type LFA1

Click Events and click create button

2005 Diagonal Consulting Pte Ltd

Find the triggering event

The event
has been
created

2005 Diagonal Consulting Pte Ltd

Find the triggering event


Double click the event

Event has
been
released

To release the event : set the status to implemented and after that set the
status to release
Menu : Edit - Change release status - Object type component - To
implemented / To released
2005 Diagonal Consulting Pte Ltd

Find the triggering event


After knowing the event that we should kick off, we need to go to SWEC to
link it to the change document
If we want to link to the super type (LFA1) we need to do the delegation from
LFA1 to ZLFA1
Delegation: SWO1 -> Settings -> Delegate -> System-wide

2005 Diagonal Consulting Pte Ltd

Find the triggering event


Test whether publishing event from change doc is working by creating a
new vendor and after that check SWEL

2005 Diagonal Consulting Pte Ltd

Find the triggering event


Double clicking the entry

Object key

Event Creator

2005 Diagonal Consulting Pte Ltd

Try to find standard template

Since there is no suitable standard template we need


to create it from scratch
2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type


Create new method Create_FI_View to call transaction FK01

2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type

Select the method and press Program button

2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type

Save and press back button

2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type


Change the status to implemented and after that generate the object type

2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type


Create new attributes : PurchOrg and AccountGroup

2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type

2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type

2005 Diagonal Consulting Pte Ltd

Enhancing LFA1 object type


Change the attributes status to implemented and generate the object type

2005 Diagonal Consulting Pte Ltd

Create standard tasks to use the methods


Create TS for method LFA1.Create_FI_View (Abbreviation : ZPU_FK01)

2005 Diagonal Consulting Pte Ltd

Create standard tasks to use the methods


Create the work item description

Create one more TS for LFA1.Display (Abbreviation : ZPU_VendDisp)


2005 Diagonal Consulting Pte Ltd

Create the workflow template


Go to PFTC -> Select Workflow Template -> Create

2005 Diagonal Consulting Pte Ltd

Create the workflow template


Create container to hold LFA1 object type

2005 Diagonal Consulting Pte Ltd

Create the workflow template


Maintain the triggering event tab

Binding
Definition

2005 Diagonal Consulting Pte Ltd

Create the workflow template

2005 Diagonal Consulting Pte Ltd

Create the workflow template

2005 Diagonal Consulting Pte Ltd

Create the workflow template

Double click

2005 Diagonal Consulting Pte Ltd

Create the workflow template

Click Activity tab

2005 Diagonal Consulting Pte Ltd

Create the workflow template

Double click

2005 Diagonal Consulting Pte Ltd

Create the workflow template

Enter

2005 Diagonal Consulting Pte Ltd

Create the workflow template

2005 Diagonal Consulting Pte Ltd

Create the workflow template

2005 Diagonal Consulting Pte Ltd

Create the workflow template


Create another activity step for standard task ZPU_VendDisp

2005 Diagonal Consulting Pte Ltd

Create standard role for FI clerks


Since the FI clerk should be determined by Vendors purchasing Org, we need
to create a responsibility role with Purchasing Org as the role container

2005 Diagonal Consulting Pte Ltd

Do the agent assignment


Set the responsible agent -> refer to a responsibility role

2005 Diagonal Consulting Pte Ltd

Do the agent assignment

2005 Diagonal Consulting Pte Ltd

Do the agent assignment

2005 Diagonal Consulting Pte Ltd

Do the agent assignment


Set the possible agent

Click the
agent
assignment
button

2005 Diagonal Consulting Pte Ltd

Do the agent assignment

2005 Diagonal Consulting Pte Ltd

Do the agent assignment

2005 Diagonal Consulting Pte Ltd

Do the agent assignment

2005 Diagonal Consulting Pte Ltd

Last steps
Generate the workflow template

2005 Diagonal Consulting Pte Ltd

Last steps
Activate the event linkage

Click this to
activate the
linkage

Result :

2005 Diagonal Consulting Pte Ltd

Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics

2005 Diagonal Consulting Pte Ltd

Monitoring and diagnostics


Monitoring
Check workflow administrators inbox (all workflow error will be sent to
administrators inbox)
SWI2_DIAG - Diagnosis of work items containing errors
Check that error monitoring job (SWWERRE) is running correctly

Diagnostics
Check SWU3
SWUD - Workflow diagnostic
SWI1 - Work item report
Workflow log
SWEL - Event trace
SM58 - Transaction RFC Log

2005 Diagonal Consulting Pte Ltd

Workflow does not start


Check whether workflow really did not start or whether it was started but
did not create the work item in the correct inbox
Use SWI1 to check whether workflow really fail to start (Is there entry for
the workflow? -> No entry means workflow failed to start
SWEL to check whether event was kicked off
Is there any exception returned by start condition or check function?
Is the workflow definition active?
Simulate the event (SWU0) to check the event linkage table

2005 Diagonal Consulting Pte Ltd

Workflow stops in mid track


Check the workflow log, concentrate on the step which is hanging
Use technical display mode
What is the work item status?
For error here are the list of error messages type
Workflow system errors (Message ID WL)
Errors that occur in business objects when expression evaluation fails,
such as during bindings (Message ID OL)
Errors that occur during agent determination (Message ID 5W)
Exceptions from the business object method called within the tasks
(Message ID other than the above message Ids usually come from the
application your method is calling)
For background methods, be careful when using BDC or CATT. Error
Message must be handled correctly

2005 Diagonal Consulting Pte Ltd

Other common problems


Background work items aborting in the middle
No result will be returned, the status remains in the STARTED status
Common cause : Incorrect or insufficient data passed to the method
BDC problem
Business Object does not exist
The binding is incorrect in the workflow definition
The object does not yet exist in the database
Multiple workflows are triggered
There are more than one active linkage for the same event
Workflow is triggered directly by a customizing table and also by an
event
Agent doesnt receive the work item
Check the responsible, possible and excluded agent
Buffer problem
Wrong agent receives the work item
Buffer problem
2005 Diagonal Consulting Pte Ltd

Developer Guide to SAP Workflow

2005 Diagonal Consulting Pte Ltd

Potrebbero piacerti anche