Object Plug-Ins (Business Add-Ins, BAdIs)

Concept

One drawback of code plug-ins is that they do not have a well-defined interface. Instead, they inherit the entire program context (including all local and global elements visible in the position in question). This makes future modifications susceptible to unexpected side effects.

Business add-ins (BAdIs) provide a solution here by offering enhancements that do not make modifications, but which must be compatible with an interface specified in advance. This interface is defined using an interface assigned to the BAdI. BAdIs are handled using the commands GET BADI and CALL BADI, where GET BADI creates a substitute object for the object enhancements present in the system. This can then be called using CALL BADI.

Example

In a system with the BAdI badi_calc_vat and an appropriate interface, customers can be responsible for calculating sales tax. Customers can then define a suitable implementation of this BAdI. This implementation consists mainly of a class that implements the BAdI interface, in this case one that contains the method get_vat_rate.

               DATA: bd TYPE REF TO badi_calc_vat,
       vat TYPE f.
START-OF-SELECTION.
  GET BADI bd.
  CALL BADI bd->get_vat_rate RECEIVING vat = vat.