Intro Developer Guide To SAP Workflow
Intro Developer Guide To SAP Workflow
Objectives
Objectives
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
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
listed above
failure)
Intangibles
Person available for other tasks
Statistics to provide measurement and then improve address issues
Audit
Workflow Terms
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
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
Workflow Customizing
Manual Customizing
Automatic
Always required?
Default Used
01
User WF-BATCH
SY-UNAME
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
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
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
Click the
agent
assignment
button
Double
Click the
step
Create
Agent
assignment
Dont
forget
Click Add
Task
Click the
Workflow
tasks button
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
Agent
Excluded
Agent
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
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
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
Click this to
activate the
linkage
Click this
button
Dialog Task
Workflow objects
Single Step Task Types
TS - Standard Task (Client and Time Independent)
T - Customer 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
Standard Task
Workflow template
Triggering
event
Workflow template
Activity step
Activity step for calling standard task (TS)
Activity step
Activity step for calling sub workflow (WS)
Condition step
To check a condition with two outcomes (True and False)
Fork step
For parallel processing
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
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
Business Object
Key fields
Database Attributes
Virtual Attributes
Combination of other attributes or constants
Explicit implementation required (self programmed)
Calculation upon attribute access
Buffering in the Business Object Builder
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
Objects in Workflow
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
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
For User
Status
Click
Processing
routines
Click
Output type
Click New
entries
Save it
Click
Condition
records
Save it
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.
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.
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
Agent assignment
Direct assignment to Organization Plan
Role resolution for responsible agent
Responsibility role
Function module role
Binding from workflow container to role container
Responsibility Role
Click
Click
Responsibilities
Container
Responsibility Role
Responsibility Role
Responsibility Role
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.
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
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
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
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
Finance to
maintain
Vendor FI
view
Notify
creator that
FI view has
been
maintained
Workflow
completed
There is no
Created
event
The event
has been
created
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
Object key
Event Creator
Binding
Definition
Double click
Double click
Enter
Click the
agent
assignment
button
Last steps
Generate the workflow template
Last steps
Activate the event linkage
Click this to
activate the
linkage
Result :
Course Contents
Introduction
Configuring the system
Agents
Creating workflow
Business Object
Events
Agent determination
Workflow development
Monitoring and diagnostics
Diagnostics
Check SWU3
SWUD - Workflow diagnostic
SWI1 - Work item report
Workflow log
SWEL - Event trace
SM58 - Transaction RFC Log