Show TOC Start of Content Area

Background documentation Architecture  Locate the document in its SAP Library structure

Definition and Implementation

In the definitions for the Enhancement Framework, BAdIs are element definitions for enhancement spots. They are processed directly in the Enhancement Builder.

BAdIs are the basis for object plug-ins that serve to enhance the functions in ABAP programs without having to make modifications. BAdIs enable the creation of enhancement options in the form of interfaces that can be appropriately implemented later on in the same system or an external system.

As with all enhancements, BAdIs make a distinction between the definition and individual implementations. The definition of a BAdI is usually created by SAP and, together with its calling points in ABAP programs, it forms explicit enhancement options in such programs.

The definition of a BAdI contains a BAdI interface, a set of selection filters, and some settings that affect runtime behaviour later on. A BAdI interface forms the entire interface or part of the interface of an object plug-in.

A BAdI implementation is the term used in the Enhancement Framework for an enhancement implementation element. A BAdI implementation consists of a BAdI implementation class that implements the BAdI interface, and of a condition imposed on the filters specified in the BAdI definition. These can be used to select the BAdI implementation.

The calling points of a BAdI are defined through the ABAP statements GET BADIand CALL BADI, which – in the definition world of the Enhancement Framework – form the enhancement spot element calls of the explicit enhancement option.

For more information about BAdI definitions, see Definition of BAdIs.

Object Types Involved

In keeping with design patterns, the command GET BADI corresponds to the call for an abstract factory. It returns – depending on the filter values and a context – an instance of a proxy object. The static constellation of the interfaces and classes involved is displayed in the following UML diagram.

This graphic is explained in the accompanying text

 

The BAdI has the name badi_name. The class shown here with the same name is a BAdI class, which is created during the definition of a BAdI in the Enhancement Builder as the final subclass of the abstract global class cl_badi_base. The BAdI class is the template for the BAdI object, and does not play any visible role (with the exception of the namespace).

The name of the BAdI interface for which badi_name is defined is if_intf and contains the predefined tag interface if_badi_interface. The BAdI interface must not contain any variable attributes. If the BAdI can be used on a multiple basis, it must not contain any methods with exporting or returning parameters. The methods of a BAdI interface are called BAdI methods.

The BAdI implementation classes cl_imp1, ... , cl_impn also implement the BAdI interface if_intf. The abstract class cl_abstract_imp displayed here is only for demonstration purposes since, in contrast to the classical BAdIs, there are no limitations with regard to the classes to be implemented provided they implement the BAdI interface only. A BAdI implementation class can even implement two different BAdI interfaces. This makes it possible when defining BAdIs, for example, to create partial implementations in the form of (abstract) BAdI implementation classes from which the actual BAdI implementation classes inherit.

Caution

The BAdI class is not a BAdI implementation class and does not really implement the BAdI interface, but merely contains references to the actual object plug-ins (objects of BAdI implementation classes).

Note

The architecture of BAdIs can be viewed also in relation to another design pattern, known as the parameterized event handler. Here, the BAdI implementation classes play the role of observers that automatically register at GET BADI for the appropriate BAdI object. The BAdI object takes on the role of subject, and method calls with CALL BADI correspond to a Notify.

 

 

End of Content Area