Some times our requirement comes like we can not use any of standard scheduling functions available to start a process chain or an infopackage or a Job.
Ex: Process chain has to start at 3 different Odd times in a day(like: 7, 12, 20 hours).
Or some chains has to be started based on some other loads success or failure...
Or we have to use same process chain multiple times instead of including more infopacakges...etc
For above requirements, to control process chain effectively it better to start Process chain or Job or infopackage through an Event.
T Code : SM62 --> To Create an Event.
T Code : SE38 --> To Create an ABAP Program
Use Function Module : BP_EVENT_RAISE to raise an event.
Scenario: First day of week weekly load has to start first. Remaining days in weeks daily load has to run 2 different times in a day(ex: 6 and 20 hours)
Steps:
1. Create a Process Chain1 and Schedule it based on event and check periodic check box.
2. Create a Process Chain2 and include below ABAP program and schedule it for every one hour(24 X7) periodically. So this chain will trigger Process Chain1, based on conditions specified in ABAP Program.
3. See below doc : How to ... Integrate ABAP Program in Process Chain
Sample Coding:SELECTION-SCREEN BEGIN OF BLOCK Daily_Loads WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN COMMENT /1(50) COMM0001.
Parameters : Dly_Ld1(2) type c.
Parameters : Dly_Ld2(2) type c.
SELECTION-SCREEN END OF BLOCK Daily_Loads.
SELECTION-SCREEN BEGIN OF BLOCK Weekly_Load WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN COMMENT /1(50) COMM0002.
Parameters : Wkly_Ld1(2) type c.
SELECTION-SCREEN END OF BLOCK Weekly_Load.
Data : hour(2) type c.
Data: l_cweek type /BI0/OICALWEEK.
Data: l_fdate type /BIC/OISSS_DATE.
Data: l_date type /bic/OISSS_DATE.
INITIALIZATION.
MOVE 'Input Daily Load Timings in 24Hour Format' TO COMM0001.
MOVE 'Input Weekly Load Timings in 24Hour Format' TO COMM0002.
clear hour.
hour = sy-timlo(2).
****Code to get First day of Fiscal Week
CALL FUNCTION 'ZBW_DATE_GET_FISCAL_WEEK'
EXPORTING
DATE = sy-datum
IMPORTING
WEEK = l_cweek.
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = l_cweek
IMPORTING
DATE = l_fdate .
move sy-datum to l_date.
START-OF-SELECTION.
if l_fdate = l_date and hour = Wkly_Ld1.
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
EVENTID = 'SSS_OBSS_WEEKLY_LOAD'
* EVENTPARM = ' '
* TARGET_INSTANCE = ' '
* EXCEPTIONS
* BAD_EVENTID = 1
* EVENTID_DOES_NOT_EXIST = 2
* EVENTID_MISSING = 3
* RAISE_FAILED = 4
* OTHERS = 5.
elseif hour = Dly_Ld1 or hour = Dly_Ld2.
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
EVENTID = 'SSS_OB_SALES_DATA_LOAD'
* EVENTPARM = ' '
* TARGET_INSTANCE = ' '
* EXCEPTIONS
* BAD_EVENTID = 1
* EVENTID_DOES_NOT_EXIST = 2
* EVENTID_MISSING = 3
* RAISE_FAILED = 4
* OTHERS = 5 .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
While execution we can specify Daily load and weekly load times in selection screen(as below). We can create variant and assign in process chain to automate.
Provide values in selection screen and save a variant.
7 Responses to how to ... start process chain through an event
Hi!
very useful your blog. Just went over it. A more personal question would be what happens with the control in the PC after executing the ABAP event raising program ?
would wait for the stand by PC to be triggered by the event to conclude or just launch the event and keep with following process chains ?
We need to schedule other process chain based on Event. Once event triggered by ABAP program other process chain starts. Till that time process chain waits for the event...
Hi Sreeni,
Its good to find out finally a blog like this. But at the same time if anyone available online for resolving the queries posted by us immediately helps a lot.
coming to the above question, U mean to say that we can start a process chain in two ways, one is by creating an event & specifying the same in scheduling options (after event)& the other way is creatign event & triggering the process chain with the help of Function module with out modifying existing process chain in Production system.
If i am wrong, Please correct it Sreeni.
Yes Kumar,
Its better to start using function module(Raise an event). or we may forgot to change the settings back..!!!
Hi,
Could you please give the code for the function module to find out the fiscal week on any given date?
It would be very helpful for me in one new requirement.
Thanks in Advance...
Regards,
Yokesh Kumar.
Hi,
It is a very useful blog. It will be very helpful for me in my new requirement.
If you could give me the code for the function module "ZBW_DATE_GET_FISCAL_WEEK", I can use this scenario in my requirement.
Thanks in Advance.
Regards,
Yokesh Kumar.
Yokesh,
instead of function module "ZBW_DATE_GET_FISCAL_WEEK" to derive Week fro Date, use standard function module: DATE_GET_WEEK.
Returns Week based on Date.
Srini
Something to say?