!--a11y-->
Tips and Tricks 
For classic BAdIs, large BAdI interfaces were frequently created in order to combine related functions.
With the new BAdIs it makes sense to divide related functions between several small BAdIs, which are then administered together in a common enhancement spot. This avoids the disadvantages of large BAdIs:
· Program termination if additionally included interface methods have not been implemented.
· Blurring the structure of an enhancement.
The instance generation mode of a BAdI can be context-dependent. With context-dependent BAdIs, you must specify an object reference variable to a BAdI context object (an object whose class implements the tag interface IF_BADI_CONTEXT) in the GET BADI statement. As a result, within an internal session for the same BAdI context object, the same object plug-ins are always used. Such object plug-ins are singletons as far as their BAdI implementation class and a BAdI context object are concerned.
Using a context-dependent BAdI is illustrated in the example below, in which a BAdI is coupled to a program.
Using the predefined global class cl_badi_report_context you can easily couple BAdI implementations to a (executable) program (or more generally, to a compilation unit). This class implements the interface if_badi_context, has a public attribute repid, and a public static method get_instance, which creates an object and sets the attribute.
By calling method cl_badi_report_context=>get_instance, you can create unique instances as far as the attribute is concerned, which can serve as BAdI context objects. Suppose the BAdI badi_ctx_badi is context-dependent and has no filters. The code fragment below shows how to use the cl_badi_report_context:
DATA: bd TYPE REF TO badi_ctx_badi,
ctx TYPE REF TO cl_badi_report_context.
ctx = cl_badi_report=>get_instance( repid = sy-repid ).
GET BADI bd CONTEXT ctx.
The reference variable ctx references an instance that is unique for the current program name. For this context, a BAdI object is requested. If the same code fragment is executed in other programs in the same internal session, different instances of the BAdI implementation classes are always associated with the BAdI object.
Thus, the class cl_badi_report_context allows you to bind object plug-ins to compilation units. The methods of these object plug-ins can be called anywhere in the internal session by using the combinations of GET BADIand CALL BADI shown above. The state is kept in this connection, which means that the same instances are always called for the same compilation units.