SAP® Business Workflow Tutorial

Triggering Events Programmatically

By Suresh Kumar Parvathaneni

Purpose: This document details the procedure in triggering the business object events programmatically. 

Pre-requisites: It is assumed that the reader of this document is aware of the business object concepts and good in ABAP. 

Procedure:

In this document, we would take an example of the business object BUS1001006 (Material) and the event CREATED. In general, this event is triggered whenever a material is created using a standard procedure like MM01 or any others. Now we would trigger this event from our own programs. 

Following are the screenshots of the business object BUS1001006 and the event CREATED. Go to transaction SWO1 for more information of the business object. 

Double-clicking on the key field parameter gives you technical information of the field.

 

In order to trigger an event programmatically, we would use the function module SWE_EVENT_CREATE. 

Following is the sample code to trigger the events programmatically: 

 
REPORT ZDEMO_TRIGGER_EVENT.

DATA: KEY LIKE SWEINSTCOU-OBJKEY.

KEY = '1163'. “ 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:

 

 

 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image