How to Implement Function Module Exits using BADI
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.
b ) Create enhancement in CMOD and activate the components. (See below screens)
c) Go to SE18 and create a BADI definition.
d) Create an instance method (public) for the BADI with parameters (if needed).
e) Create implementation for the BSDI.
f) Here, see the method (public) created in definition is already assigned to your implementation (EXIT_SAPLFMR4_002).
g ) Apply the validation in the public method and business logic in private method. Call the private method in the public method after validation.
Now, next step is how to call the BADI from the customer exit.
a) Go to your customer exit program.
b) Create an instance of your BADI interface and call the public method (e.g. EXIT_SAPLFMR4_002).
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,
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.
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 🙂
PS - Can we have your experience with custom Kernel BAdIs documented as a blog/document in SCN? 😳
Yes I will try and blog it when I find time. I've done this recently in my current project.
Suhas, here it is:
Simplify & structure your Enhancements by using Switchable Kernel BAdIs
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.
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,
For the above reasons, an automatic call migration is not possible.
In that case how it will work ?
Nice one. But this solution is already provided in 2007 i guess.
Praveen, I'm not sure I understand your question.
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.
Praveen Its really very useful blog on classic BADIs. 🙂
Good one... Very useful..next time i will try this one for my new developments.
Thanks for sharing. 🙂
Thanks Rajesh for Acknowledgement 🙂
Good articel. Very informative for a newbie like me 🙂 .
Nice informative 🙂
Thanks shamala 🙂