07-03-2007 5:18 AM
whats the program for triggering the event using function module in workflow....
07-03-2007 5:22 AM
hi
In order to trigger an event programmatically, we would use the function module SWE_EVENT_CREATE.
BUS1001006 ( Standard Material )
here is the sample code.
DATA: key LIKE sweinstcou-objkey.
key = '68." Material Number (hard-coded)
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'BUS1001006'
objkey = key
event = 'CREATED'
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 =
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.
ELSE.
WRITE 'Event Triggered'.
ENDIF.
COMMIT WORK.
************************************************************************
In order to test whether the event is getting triggered or not, we can make use of Event Trace. Switch on the event trace using the transaction SWELS.
Press Switch On.
Now execute the program developed earlier. Now switch-off the event trace using the same transaction SWELS.
Now go to transaction SWEL. Here you can list out the events triggered in the particular period of time. Here is the event-trace list:
also
Data for workflow trigger
DATA: objtype LIKE swetypecou-objtype,
objkey LIKE sweinstcou-objkey,
event LIKE swetypecou-event,
event_container LIKE swcont OCCURS 0 WITH HEADER LINE.
objtype = 'ZBUS1001'. "Material [sub object of BUS1001]
MOVE v_wfmatnr TO objkey. "V_WFMATNR is material number
event = 'CreatePLMMaterial'."Custom Event defined in
ZBUS1001 [Tcode SWO1]
REFRESH event_container.
*Following are the Event parameters required in the *Workflow
swc_set_element event_container 'Attachment' v_wfattachment.
swc_set_element event_container 'Material' v_wfmatnr.
swc_set_element event_container 'TisGroup' v_wftisgroup.
swc_set_element event_container 'SchDate' v_schdate.
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = objtype
objkey = objkey
event = event
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.
COMMIT WORK.
In TCode SWETYPV Create entry for Object type Event and Workflow ID.
In my case Object type is ZBUS1001
Event CreatePLMMaterial
Rec type = <Workflow ID>
also check with the link
https://forums.sdn.sap.com/click.jspa?searchID=2650853&messageID=3074200.
http://help.sap.com/saphelp_nw04/helpdata/en/c5/e4af8b453d11d189430000e829fbbd/frameset.htm
Hope this helps to solve ur problem....
do reward if useful....
regards
dinesh