Thursday, September 5, 2013

Event Based Process Chains

There may be a requirement where you may need to schedule a process chain after an event is being triggered.


In this Example I have a process chain A runs weekly, when completed should trigger an event which will result in execution of Process chain B.


Steps to be followed is as follows :


Step 1) Create an Event-->    Go to Transaction code SM62   --> Select  BckProcEvnts tab  --> Create an event.


Image


In the snapshot  above  we can see I have created an Event 'ZTEST'.


Step 2) Create variant for Program ''BTC_EVENT_RAISE"


    Go to se38 --> Enter Program name 'BTC_EVENT_RAISE'---> Select Variant radio Button --> Click Display


Image


Enter a name for Variant and click 'Create'.


 Image


In the following screen, enter the event name which you have created in SM62 (in Step 1). In my case I had created 'ZTEST' Event.Image


Click on Attributes , enter description for variant  and click on 'Save'


Image


Step 3) Go to Process Chain A


At the end of your Process chain, insert process type 'ABAP Program'.


Image


In the next Screen insert  the ABAP Program 'BTC_EVENT_RAISE'.


Enter the variant created in Step 2.


Image


Your Process chain A will look like this


Image


Schedule process chain A as per your requirement .Example I scheduled it weekly, (on Sunday, Morning 6 AM)


Image


Step 4  ) Go to your RSPC and open Process chain B


Go to Start Variant --> Change selections --> After Event --> Enter the Event Name created in Step 1.


Check box 'Periodic job'


Image


Now , every Sunday 6 am Process chain A  gets executed. As soon as the ABAP Program is completed  in the last step of Process chain A, event ZTEST is gets triggered and as a result of that Process chain B starts.


So you get the desired result as per event based scenario.