Many BI developers have faced the need to automate the execution of process chains, which can be easily done within BI. However, sometimes we face the challenge to have BW process chains executed once specific ECC jobs complete successfully.
This document will walk through having an ECC job(s) trigger a BW process chain, and illustrate that it’s not really that challenging as it seems.
We have two ECC jobs which once completed, should trigger the corresponding BW process chain. In this example, the ECC jobs can be run in parallel, and only when both complete, the BW process chain is triggered.
1. In RSPC create the process chain that will be triggered from ECC:
2. In SM64, create an event that will be used to trigger the process chain from step 1. For simplicity, use the same technical name of the process chain.
Click on new, provide the technical ID of the event and a description, and save the event.
The Event is what will be passed from ECC through the remote function call to BW. The process chain will have a start condition that will be after the event has been called. Details on step 3
3. Go back to the process chain, into the start variant, make sure you’re in change mode, under Scheduling Options, select Direct Scheduling, click on Change Selections:
In the selection options, chose After Event, and in the event section, chose the event that was defined in step 2, which should be the exact same technical ID as the process chain.
Ensure Periodic Job is selected, as this will enable the job to be scheduled and run periodically, as opposed to a single run. Check and Save, then save again.
4. In BW, we need to create a remote enabled Function Module, that will be called from ECC with the Event ID, and that will pass that Event ID and raise the event (fancy words for executing the event).
Go to SE37 and create a FM with ID ZFM_TRIGGER_EVENT
Ensure that Remote-Enabled Module is selected, as we want this FM to be triggered from ECC
Under Import, add the Event parameter details as shown below:
All other tabs can be left AS-IS.
Under Source Code, add the code below:
Here’s the actual code to copy paste:
CALL FUNCTION ‘BP_EVENT_RAISE’
EVENTID = event
* EVENTPARM = ‘ ‘
* TARGET_INSTANCE = ‘ ‘
* TARGET_MODE = ‘ ‘
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 5.
IF SY–SUBRC <> 0.
* Implement suitable error handling here
Save and activate your function module.
1. Firstly, we’ll need to create a program that will take the user/developer’s input as to which process chain will be executed, and in which system. In reality, the input for the process chain is really the EVENT that we setup in the BW step 2, but since we’re using the same technical ID for the event and process chain, that will not be an issue.
The advantage of creating a program with open input, is that we don’t hard code the BW system and process chain, and it can be re utilized for other process chains. We also have the advantage of being able to use this program in each BW environment in the stack (Dev, Quality, Prod) without changing code.
Go to SE80 and create a program ZBW_TRIGGER_EVENT:
Create three includes below:
This will be the definition of the layout of the program:
P_LS will be the selection option for the logical system
P_PC will be the selection option for the process chain
Below is the code to copy/paste.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text–002.
PARAMETERS: p_ls TYPE rsds–logsys.
PARAMETERS: p_pc TYPE rspcchain–chain_id.
SELECTION-SCREEN END OF BLOCK b1.
This will validate the selection input by the user
We do not want the program to execute if any of the selection options are blank
Below is the code to copy/paste:
sy–title = text–001.
IF p_ls IS INITIAL.
WRITE:/ ‘Please enter BW System ID’.
ELSEIF p_pc IS INITIAL.
WRITE:/ ‘Please enter Process Chain Technical Name’.
This will trigger the Function Module ZFM_TRIGGER_EVENT that we created in BW in step 4, passing the process chain (event) and the logical system
Below is the code to copy/paste:
CALL FUNCTION ‘ZFM_TRIGGER_EVENT’ DESTINATION p_ls
event = p_pc.
We now need to maintain the text elements for our program. Go to GOTO -> Text Elements -> Selection Texts
Maintain the texts for the symbols that were used:
Maintain the selection texts for the variables that we’re using:
Save and activate the program.
2. Now that the main program has been created, we need to create a variant for it, with our logical system and process chain.
Go to SE38 and execute program ZBW_TRIGGER_EVENT. Enter your BW system and process chain.
Hit the save button to create a variant:
The program is now ready to be scheduled.
3. Now we will schedule the jobs that we want to run periodically in ECC, that will trigger the BW process chains. One job will be to execute the ABAP program that will be scheduled on a regular basis. The second job will only be executed after the first job completes, and will trigger the ZBW_TRIGGER_EVENT program created above.
Go to SM36 and create your periodic job. Once you defined the name, hit enter
Create the step, which is the ABAP program you wish that job to execute. In my case, I will be using my dummy ZBWTEST program.
Variants for the program to be executed are required, so make sure to create one ahead of time.
Check and save. You have successfully added the program to that job to be scheduled.
To add a second or multiple programs to that single job, simply click the new button, to add additional steps, and following the same process above.
Hit the back button to take you to the main job screen. Select the Start Condition button to define the start time/frequency, then save.
Once you’re back in the main job screen, make sure to save again. Only then you will get a message on the bottom bar that the job was released:
Go to SM37 and check that the job ran and has finished:
We now need to copy this job and keep it in status scheduled. This is required for the second job that we will create that will be triggered once Z_JOB completes. Copy Z_JOB and keep the same name and do not release it. Leave it as scheduled:
Step 4. Now we will create the second job that will kick off after Z_JOB completes, and that will trigger the ZBW_TRIGGER_EVENT program.
Select the ZBW_TRIGGER_EVENT as the program, and the variant that you created then check and save
The step will be created under that job. Go back one page.
Under Selection Criteria, chose After Job, and enter Z_JOB as the job name, and check Start Status-Dependent. This will ensure this job only starts if the previous one completes successfully.
Check and save.
Save again in the main page, and you will get the message at the bottom that it was saved and is in status released.
Go to SM37 and ensure all options are selected. In order to see the Z_BW_TRIGGER job, select the Extended Job Selection button. Under the start conditions tab, in the OR start after job row, enter the predecessor job Z_JOB, and then execute
You should now see both jobs in the scheduler.
Your development is complete. You can now schedule the Z_JOB to run in ECC and watch the jobs kick off the process chain in BW.
Hope this was helpful. Good luck!