Sunday, October 10, 2010

Passing Multiple Values to Workflow

Passing Multiple values from the triggering program to Workflow.

First we need to declare the event container variables for the required event.

See the screen shots for creating event container variables.







Now we have defined the event container variables.

After that we need to do the coding in the workflow triggering point.

*-- For Passing Event Container Values
INCLUDE .
swc_container wf_contnr.
*-- create the container of type container
swc_create_container wf_contnr.
swc_set_element wf_contnr 'EvtParameter1' p_gwf_onrname.

*-- Triggering the workflow ( note that we are passing the event container )

CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'ZEHS_RA'
objkey = p_gwf_entryno
event = p_gwf_event
* CREATOR = ' '
* TAKE_WORKITEM_REQUESTER = ' '
* START_WITH_DELAY = ' '
* START_RECFB_SYNCHRON = ' '
* NO_COMMIT_FOR_QUEUE = ' '
* DEBUG_FLAG = ' '
* NO_LOGGING = ' '
* IDENT =
* IMPORTING
* EVENT_ID =
* RECEIVER_COUNT =
TABLES
event_container = wf_contnr
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.
COMMIT WORK.

***************************************************
Please see one example program
***************************************************
*-- For Passing Event Container Values
INCLUDE .
swc_container wf_contnr.
* swc_container wf_contnr1.
swc_create_container wf_contnr.
* swc_create_container wf_contnr1.
IF p_gwf_onrname IS NOT INITIAL AND p_gwf_onrname NE space.

swc_set_element wf_contnr 'NextLevel' p_gwf_onrname.
swc_set_element wf_contnr 'Initiator' sy-uname.
ENDIF.
IF p_gwf_onrname IS INITIAL.
swc_set_element wf_contnr 'Initiator' sy-uname.
ENDIF.
*--------------------------------------------------------------*


CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'ZEHS_RA'
objkey = p_gwf_entryno
event = p_gwf_event
* CREATOR = ' '
* TAKE_WORKITEM_REQUESTER = ' '
* START_WITH_DELAY = ' '
* START_RECFB_SYNCHRON = ' '
* NO_COMMIT_FOR_QUEUE = ' '
* DEBUG_FLAG = ' '
* NO_LOGGING = ' '
* IDENT =
* IMPORTING
* EVENT_ID =
* RECEIVER_COUNT =
TABLES
event_container = wf_contnr
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.
COMMIT WORK.

No comments: