BAdI – Basics
With a BAdI, an SAP application provides the enhancement option through an interface and an adapter class implementing that interface.
The interface can be implemented by several users in the delivery chain, thus, multiple BAdI implementations are possible. Additionally, a BAdI implementation itself can provide another BAdI, which can be implemented by users who appear further out in the delivery chain.
When you define a BAdI, you must specify an interface (IF_EX_<badi>) with corresponding formally defined methods. The adapter class that is automatically generated during the interface definition (CL_EX_<badi>) has, among other capabilities, the function of calling all active implementations of the BAdI. When you have several active implementations, there is no predefined processing sequence.
To Define a BAdI
Steps
The BAdI Calling Program
The figure shows an example of a BAdI call.
A reference variable for the type of BAdI must be defined.
An object of the adapter class is instantiated by the call of the GET_INSTANCE static method of the CL_EXITHANDLER class. The variable gb_adapter points to this instance.
The interface methods of the BAdI can be called by gb_adapter object reference.
The Search for BAdIs
You can search the BAdI using the following strategies:
BAdI Implementation
When the name of the BAdI is determined, the BAdI can be implemented. The implementation of the BAdI is performed through the implementation maintenance under Tools → ABAP Workbench → Utilities → Business Add-Ins → Implementation (transaction code SE19). Alternatively, you can go to the implementations by navigating the menu from the BAdI definition.
To implement a BAdI, a BAdI implementation name must be issued. The naming convention is Z<impl>. A dialog box then appears for selecting the corresponding BAdI.
The code to be implemented is stored in a method of an automatically generated customer class. For this reason, the name of the implementing class must be given in a final dialog box. The default name from SAP is comprised of Y or Z (the namespace prefix), CL_ (for class), IM_ (for implementation), and <impl> (the actual name of the implementation).