Workflow creation and Customization

Basically I want to call a workflow from a Back Ground program. Can you tell me 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 ZTESTING1 .

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.

Read Also
Useful TCodes Used In SAP Workflow

SAP WF Reference Books:
SAP Workflow Configuration, Interview Questions and Certification, Books

Back to:
SAP Business Workflow Hints and Tips

Return to :-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.