Hi Developers ,

Consider a scenario in which you are going to create BADI definition as well for a customer exit.

Here are the steps:

a ) Find out the correct customer exit for your requirement from the functional team.


      /wp-content/uploads/2013/09/1_281728.png

b ) Create enhancement in CMOD and activate the components. (See below screens)

     /wp-content/uploads/2013/09/2_281867.png

       /wp-content/uploads/2013/09/3_281868.png

         /wp-content/uploads/2013/09/4_281869.png

c)   Go to SE18 and create a BADI definition.

       /wp-content/uploads/2013/09/5_281870.png

d)  Create an instance method (public) for the BADI with parameters (if needed).

        

       /wp-content/uploads/2013/09/6_281871.png

          /wp-content/uploads/2013/09/7_281872.png

e)  Create implementation for the BSDI.

                /wp-content/uploads/2013/09/8_281873.png

                    

                     /wp-content/uploads/2013/09/9_281874.png

f)     Here, see the method (public) created in definition is already assigned to your implementation (EXIT_SAPLFMR4_002).

               /wp-content/uploads/2013/09/10_281875.png

               

g )  Apply the validation in the public method and business logic in private method. Call the private method in the public method after validation.

         

               /wp-content/uploads/2013/09/11_281876.png

                 /wp-content/uploads/2013/09/12_281877.png


Now, next step is how to call the BADI from the customer exit.

                         

                       

a)  Go to your customer exit program.

                      

                     /wp-content/uploads/2013/09/13_281878.png

b)  Create an instance of your BADI interface and call the public method (e.g. EXIT_SAPLFMR4_002).

      

                     /wp-content/uploads/2013/09/14_281879.png

                       /wp-content/uploads/2013/09/15_281880.png

c) The BADI (ZBADI_ZXFMCU08) is multiple uses BADI. In future if there requirements for the same customer exit, create a new implementation and a private method to apply logic in the BADI.


Hope this blog will prove helpful ,Pls feel free to reach out for anything ! 😉

Thanks and Regards,

Praveen Srivastava

To report this post you need to login first.

17 Comments

You must be Logged on to comment or reply to a post.

  1. Sougata Chatterjee

    Praveen,

    I think a better approach would be to create a Kernel BAdI (New BAdI) instead as they are much much faster than the Classic BAdIs. You can then have multiple implementations on your custom BAdI Definition that you have defined in your Enhancement Spot if required.

    You would need to call it like GET BADI followed by CALL BADI statements instead of calling cl_exithandler=>get_instance. You don’t need to keep the BAdI instance in your calling program if you mark it as “Reusing Instantiation” in the instance creation mode of your enhancement spot.

    This same technique can also be used to convert the Classic BAdIs into the new Kernel BAdIs/Enhancement Spots to be able to improve performance especially on the complicated dialog transactions etc.

    Cheers,

    Sougata.

    (0) 
    1. Suhas Saha

      Hello Sougata,

      Honestly i have never created a custom BAdI; but i have used “Strategy” design pattern to achieve something similar.

      But your suggestion to create custom Kernel BAdIs sounds appealing to me. Next time i have such a requirement that’s the first thing i’m gonna do 🙂

      BR,

      Suhas

      PS – Can we have your experience with custom Kernel BAdIs documented as a blog/document in SCN? 😳

      (0) 
  2. Eric Peterson

    Great post Praveen.  It’s nice to see some originality in a blog post and not just a summary of something already documented by SAP.  This adds the multiple implementation functionality to the classic user exits, I never thought about doing that.  Though I agree with Sougata’s suggestion to use New BAdIs instead of Classic BAdIs.

    (0) 
  3. praveen srivastava Post author

    Yes sougata ,

    I do agree with your suggestion of implement kernel BAdis instead of classical BAdis,but can u explain me one point while calling BAdi,

    A classic BAdI can be called only once and the call positions are

    registered centrally.

    With new BAdIs, multiple calls are possible and the call positions are

    not registered centrally.

    For the above reasons, an automatic call migration is not possible.

    In that case how it will work ?


    Regards,

    Praveen Srivastava

    (0) 
  4. Rashid Javed

    Interesting idea Praveen!

    I like this blog because it opens up so many possibilities.

    And it also makes the code cleaner and managable in customer exits.

    (0) 

Leave a Reply