1. Business Scenario:
Execute a process chain step based on the value of a field from a table.
- e.g. If ztable-zflag = ‘X’ then execute step1 else execute step2.
In our case, the table to be referred is ZDECISION. Here, we have 2 fields: Process Chain Name and Flag.
Using the Decision Between Multiple Alternatives Process Type, check whether the flag for a particular process chain is checked or no. If it is checked, then execute Step 1, else execute Step 2.
2. Steps to create a Custom Function
1. Using SE19 create a new implementation of BAdI RSAR_CONNECTOR:
2. Enter the Implementation Name:
3. Enter the short text for your Implementation and make a note of the Implementing Class Name in the Interface tab:
4. Save your implementation. Then using SE24, edit the implementing class:
Enter your new method here. This is where you add your ABAP code for the new formula to be used in your process type. The method should be Static and Public.
5. Click the Parameter button to enter the parameters of the method. Note that only Importing, Exporting and Returning types are valid. Also, only a single exporting or returning value is permitted.
6. Click on the Methods button. Then double click on the method name to enter the ABAP code:
7. Test, save and activate your method then come back to the main SE24 screen and activate the class.
8. Using SE19 edit your BAdI implementation
9. On the Interface tab, double click on the GET method to edit the ABAP code.
The code here allows the method that we have created above to be seen in the formula screen (as part of the Functions) in the Decision Between Multiple Alternatives process type:
The first part of the code (WHEN ‘ ‘) sets up a new category in the Functions drop down menu called BW Custom Functions.
The second part of the code (WHEN ‘C_BW_CUSTOM’) adds the new method created to the BW Custom Functions.
10. Activate your code then activate the BadI. Note that when it is activated the Runtime Behaviour field will be set to “Implementation will be called”.
3. Steps to use the New Function in the Decision Between Multiple Alternatives Process Type:
1. Create/Modify Process Chain using RSA1 – Add the Decision Between Multiple Alternatives Process Type:
2. Define your conditions to check the Flag for the respective process chains. The new Function created will be available under ‘BW Custom Functions’:
As per the method defined in point 6, the above function will check whether the Flag for the process chain is checked (Value ‘0’ if the Flag is checked, else it returns ‘1’).
3. Go back to the previous screen, where you can define the Event Options in each case. Here, we have defined that If the Flag is checked, then Option 2 (Green) should be triggered, else Option 1 (Red) will be triggered.
4. Finally, use this Process Type in your process chain:
In this case, If the Flag is checked, then the Program will get triggered, else the Infopackage will trigger.