|
Starting and Event to kick off a job |
|
|
|
|
Written by Kevin Wilson
|
|
Monday, 23 July 2007 |
Ever needed to kick off a job from another external system? This tip shows you how to kick off an event. A background job is then created in SM36 that waits for this event to occur. Scheduling this job as a periodic job will cause this job to be kicked off each time this event happens. It has the ability to send in a parameter which allows you to configure the ABAP of the job to react differently based on the event parameter. Use SM62 to create the user defined event.
Events let you start background jobs when particular changes in the SAP system take place. When an event occurs, the background processing system starts all jobs that were scheduled to wait for that event. http://help.sap.com/saphelp_nw04s/helpdata/en/fa/096e2a543b11d1898e0000e8322d00/frameset.htm
Events have meaning only in the background processing system. You can use events only to start background jobs.
Triggering an event notifies the background processing system that a named condition has been reached. The background processing system reacts by starting any jobs that were waiting for the event. http://help.sap.com/saphelp_nw04s/helpdata/en/fa/096e37543b11d1898e0000e8322d00/frameset.htm
Use function module BP_EVENT_RAISE to trigger an event from an ABAP program or BAPI_XBP_EVENT_RAISE from an external system.
Example * Report processing before triggering event... * * Trigger event to start background jobs waiting for the event. * DATA: EVENTID LIKE TBTCJOB-EVENTID. DATA: EVENTPARM LIKE TBTCJOB-EVENTPARM.
EVENTID = 'SP_TEST_EVENT'. " Event name must be defined " with transaction SM62.
EVENTPARM = 'EVENT1'. " Optional: a job can be " scheduled to wait for an " EVENTID or combination of " EVENTID and EVENTPARM.
CALL FUNCTION 'BP_EVENT_RAISE' " Event is triggered. Jobs EXPORTING " waiting for event will be EVENTID = EVENTID " started. EVENTPARM = EVENTPARM TARGET_INSTANCE = ‘ ‘ " Instance at which an event " should be processed. Can " generally be omitted. EXCEPTIONS OTHERS = 1. " Exceptions include event not " defined, no EVENTID " exported, etc.
Related Items:
|