Login Form

Best viewed in IE 7.0

ADVERTISEMENTS
ADVERTISEMENT

How to call a workflow from a background program

You can use the following function modules to trigger the workflow templates, in background.

SWE_EVENT_CREATE can be used to trigger an event statically, (If triggering events are defined for your workflow template. Also check whether the event linkage is active or not)

SAP_WAPI_START_WORKFLOW can be used to trigger the workflow template directly.

This is the sample code, used in one of my objects, for calling the function module SWE_EVENT_CREATE.
REPORT ZTEST. 
tables :
ZOPM_OBJKEY.
data :
* object key
objectkey type SYSUUID_C,
objkey like sww_contob-objkey.
* defining the event container.
data begin of event_container occurs 0. 
include structure swcont.
data end of event_container.
* workitem list
data :
t_wid like SWOTOBJID occurs 0 with header line.
clear event_container.
refresh event_container.
CALL FUNCTION 'SYSTEM_GET_UNIQUE_ID' 
EXPORTING
DCE_COMPATIBLE = 1
IMPORTING
UNIQUE_ID = objectkey.
objkey = objectkey.
clear objectkey.

call function 'SWC_ELEMENT_SET'
exporting
element = 'CONTEXT'
field = 'UAD'
tables
container = event_container
exceptions others = 1.

call function 'SWC_ELEMENT_SET'
exporting
element = 'SUBJECT'
field = '3333'
tables
container = EVENT_CONTAINER
exceptions others = 1.

CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'ZPSKUMAR'
objkey = objkey
event = 'GENERIC'
* CREATOR = ' '
* TAKE_WORKITEM_REQUESTER = ' '
* START_WITH_DELAY = ' '
* START_RECFB_SYNCHRON = ' '
* NO_COMMIT_FOR_QUEUE = ' '
* DEBUG_FLAG = ' '
* NO_LOGGING = ' '
* IDENT =
* IMPORTING
* EVENT_ID =
TABLES
EVENT_CONTAINER = EVENT_CONTAINER
EXCEPTIONS
OBJTYPE_NOT_FOUND = 1
OTHERS = 2 .
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ADVERTISEMENT
Free software downloads