15 Jul 2009

Scheduling Process Chain multiple times a day using Events

On high level, following are the Steps
1)Create an event Eg : 'Z_REDCOP_DAILY_LOAD_CHAIN_EVENT'
2)Create a Program to call the FM : BW_EVENT_RAISE by passing event id like below ( we used Z_BW_EVENT_RAISE here )
3)Create a Job at frequency of 2 hours.( in SM36 ).In the step information of the job specify the above program created
4)Specify the eventid in the process chain start variant also.

Explanation : Step 1
a) Goto Sm62.
b) Open last tab
c) Click on Creat button and give technical name/desc of the event.


Explanation : Step 2
REPORT ZBW_EVENT_TRIGGER_PROGRAM.
DATA : EVENTID LIKE TBTCO-EVENTID.
DATA : DATE TYPE SY-DATUM.

DATE = SY-DATUM.
IF DATE+06(02) LE 16.
EVENTID = 'Z_REDCOP_DAILY_LOAD_CHAIN_EVENT'.

CALL FUNCTION 'Z_BW_EVENT_RAISE'
EXPORTING
EVENTID = EVENTID
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
BP_EVENT_RAISE_OTHERS = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
ENDIF.

ENDIF.

Explanation : Step 3
a) Open Sm36.
b) Give Job name and target system. Save

c) If it asks for ABAP program then give our program name ( if notClick on STEP button and it will ask ). Give variants if necessary.

d) Click save. It shows :

e) Now go back to main screen and click on start condition and give 2 hours periodic setting there.
f) Save.
g) Check in Sm37 if job is scheduled….


Explanation : Step 4

Specify the eventid in your Start variant of the process Chain.