Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
pranit_bankar
Advisor
Advisor

Background:


The standard SAP software provides many functionalities which can be further enhanced using the Enhancement Framework. One of the technologies offered as part of this Framework is Business Add-Ins (BAdIs). A BAdI could be a new BAdI (also called as Kernel BAdI) or a classic BAdI. Whenever the term BAdI is used without any prefix, it usually refers to the new (a.k.a. Kernel) BAdI.

A BAdI can have any number of implementations. However, depending on how many of these implementations can be active at any given time, the BAdIs are classified as either single-use BAdIs or multiple-use BAdIs. Both the names are self-explanatory with regards to their behavior.
Note: While using filters with BAdIs, a single-use BAdI can have one active implementation per filter value combination

In this blog, we shall be focusing on multiple-use BAdIs. SAP Help defines a multiple-use BAdI as:
Multiple-use BAdIs allow multiple implementations to exist in parallel and it is also possible to have no implementation at all. With multiple implementations in place there cannot be a single return value; therefore the methods of the interface of a multiple-use BAdI must not have "returning" or "exporting" parameters. This type of BAdI is not used to compute results but enables one or more activities to be executed at a certain point in time. Multiple-use BAdIs can be used to implement an event mechanism that allows multiple implementers to specify their individual reaction to some event.

- SAP Help

With this introduction of a multiple-use BAdI, a question could pop up in your mind whether the order or sequence of these BAdIs can be controlled or not, especially if you are already versed with Enhancement Points.

The answer to this question is a resounding yes. In this blog post, we shall focus on how to define the sequence for our multiple BAdI implementations.

Prerequisites:


This post assumes that you are already well versed with creating new BAdIs, setting them for multiple-use, and creating and activating BAdI implementations. For example, I have created my own BAdI and two implementations. The BAdI interface and implementation have been defined very simplistically, specifically to focus on defining the sequence for calling these implementations.

Let's get down to business



  1. Start with creating your BAdI, setting it as multiple-use and defining its interface. Activate all the changes.

    My example BAdI


    My BAdI interface contains only one method without any parameters:

    My example BAdI interface



  2. Create multiple implementations for your BAdI and activate them too. I have created two implementations and each implementation just prints a number onto the screen.


    Sample Implementation 1



    Sample Implementation 2



  3. (Optional) Test the BAdI and its implementations. I created a test report program:


    Test report


    On executing the report, we get:


    Test report output



  4. Now, to change the sequence of the implementation calls, create an implementation for the BAdI: BADI_SORTER. A sample implementation class has already been provided. Just copy the sample class.


    Create an implementation



    Copy the example implementation class 


     

  5. Provide a filter value for your implementation.


    The filter value is your BAdI definition (name)



  6. Add a screen enhancement for your BAdI. There are two options you can use to decide the sequence of your implementations. These options can be viewed as different screens under the standard program: SAPLENH_BADI_SORTER_SUBSCREENS. We shall be using screen number 2000 for our example, as it is quite simple to understand and use. (The other is 3000)


    Use one of the standard sub-screens



  7. Activate your implementation and copied class 

  8. Go back to the implementations of your BAdI. You can now see an additional sub-screen with the title "Layer" containing a single field "Layer Value", for each of your implementations. Enter any number of your choice for the "Layer Value". Note that the implementations would be sorted based on this value. In my example, I have chosen "Filter Value" as '2' for my 1st implementation (the implementation which prints the number 1) and '1' for my 2nd implementation.


    Add a filter value for the 1st implementation



    Add a filter value for the 2nd implementation



  9. Activate your changes 

  10. (Optional) Repeat Step 3. The results are different now.


    Test report output





Conclusion: 

In this post, we learnt how to control the sequence of implementation calls for a multiple-use BAdI 

Further Reading: 

You can also explore screen number 3000 under the program SAPLENH_BADI_SORTER_SUBSCREENS, and choose the one which best suits your use case. 

 

Ciao!