Start of Content Area

Background documentation Features of New BAdIs  Locate the document in its SAP Library structure

The definition and implementation of BAdIs are completely unaffected by changes to the source code of the compilation units in which BAdI methods are called: You create BAdI definitions in the package of the relevant enhancement spot, which belongs to a separate package. A BAdI implementation’s package assignment is determined by the enhancement implementation to which this implementation is assigned. As a programmer, you define and implement BAdIs using the corresponding tools, which can also be called in the Object Navigator (SE80). The independence of BAdI definitions and implementations of source code units, at which BAdIs are called, is an advantage of BAdIs over source code enhancements, whose implementation – that is, the relevant source code plug-in – coincides with the implementation call and resides in the corresponding source code unit. If this unit is changed, the implementation of a source code plug-in could be lost, something that cannot happen with BAdIs for the stated reasons.

BAdIs also allow you to easily add multiple levels of enhancements, and you can do so without modifications since the levels are in different packages than the call position and the definition of the BAdI. Core developers can thus create a BAdI with a default class. A default implementation is added to the application and customers can include individual BAdI implementations. The following prioritization applies at runtime:

If no active BAdI implementation(s) exist(s) corresponding to the filter conditions, the system uses the relevant default implementation(s). If no corresponding default implementation(s) exist either, an implementation of the default class is used.

Depending on the type of the definition, there are BAdIs that must have one active implementation and others for which no or multiple active implementations are possible. Single-use BAdIs have completely different semantics to their non-single-use counterparts:

·        Calling a method of a single-use BAdI (using CALL BADI) corresponds to a method call. Exactly one implementation must exist. The method of the implementation of this instance is then called. If there are no or multiple active implementations, different exceptions are raised in each case. One example are all method calls that deliver a return value. If you call such a method, you require a result. In these cases, you use single-use BAdIs.

·        Calling a method of a non-single-use BAdI corresponds to an event. No or multiple implementations can be subscribed, so to speak, to this event. How many implementations this is, if any, is irrelevant for the logic of the program flow at the position where the event is triggered or the BAdI method is called. Semantically, you use non-single-use BAdIs where additional things can but must not occur. An example of this: You want to store specific results in other destinations, such as an XML file, a database table of an external database, or a serial file.

 

End of Content Area