ABAP Keyword Documentation →  ABAP − Reference →  Enhancements →  Enhancements Using BAdIs → 

GET BADI  Syntax Diagram

Short Reference

Syntax

GET BADI { badi [FILTERS f1 = x1 f2 = x2 ...] }
       | { badi TYPE (name)
              [ {FILTERS f1 = x1 f2 = x2 ...}
              | {FILTER-TABLE ftab}] }
              [CONTEXT con].

Extras:

1. ... FILTERS f1 = x1 f2 = x2 ...

2. ... FILTER-TABLE ftab

3. ... CONTEXT con

Effect

This statement generates a new BAdI object and sets the BAdI reference to the object in a BAdI reference variable badi. This statement has a static and a dynamic variant.

To declare values for the BAdI's filters, you can declare the addition FILTERS in the static variant, or addition FILTER-TABLE in the dynamic variant.

In the case of a context-free BAdI, addition CONTEXT cannot be declared. In the case of a context-specific BAdI, however, it must be declared.

After instancing, the program searches for BAdI implementation classes for the BAdI as follows:

  1. Only BAdI implementation classes are selected that are assigned to a BAdI implementation that has the status active.

  2. Only BAdI implementation classes are selected that are assigned to a BAdI implementation (an enhancement) that have a switch in the status on. If no switch is assigned to a BAdI implementation, it is treated in the same way as an implementation with a switch in the status on.

  3. All BAdI implementations are selected that satisfy the above requirements and for which the filter condition of the BAdI implementation matches the values declared after FILTERS or in ftab. If no BAdI implementations are found with the filter specifications, the system searches for BAdI implementations that are marked as standard implementations. If there are also none of these, the fallback BAdI implementation class of the BAdI is used (if one exists).

  4. If, for a BAdI defined for single use, multiple BAdI implementation classes with matching filter conditions have been found, then a conflict solution is carried out. A successful conflict solution results in exactly one priority conflict-solving enhancement implementation and only its BAdI implementation class is selected. If several conflict-solving enhancement implementations have the same priority or if there are no conflict-solving enhancement implementations at all, then a correct conflict solution is not possible and several BAdI implementation classes will remain in the hit list.

If the resulting hit list is suitable for the definition of the BAdI which means:

then references to object plug-ins of the found BAdI implementations are saved in the BAdI object. Object plug-ins that do not yet exist are generated for this purpose. Whether an existing object plug-in is generated or reused, or whether a new object plug-in is generated, depends on whether the BAdI is context-free or context-dependent, and depends on the CONTEXT addition. The precise semantics are described in the addition.

If the hit list contains no or multiple BAdI implementations although the BAdI is defined for single use, an exception occurs. If the BAdI reference variable badi is given a valid BAdI reference before the statement in an exception case, this is retained, otherwise it is initialized.

Notes

Addition 1

... FILTERS f1 = x1 f2 = x2 ...

Effect

After addition FILTERS, the elementary data objects x1, x2, ... must be declared for all f1, f2, ... filters of the BAdI. If a filter in the BAdI has the property Constant Filter Value at Call, only literals and constants can be declared. The data objects must be compatible with the data type of the filters. FILTERS cannot be declared for a BAdI without filters.

Addition 2

... FILTER-TABLE ftab

Effect

Using the special internal table ftab, this addition assigns values to the filters of a dynamically declared BAdI. The internal table must have table type BADI_FILTER_BINDINGS from ABAP Dictionary. When statement GET BADI is executed, the table must contain exactly one row for each of the BAdI's filters. The table columns are:

The column NAME is the unique key of the sorted table ftab.

Addition 3

... CONTEXT con

Effect

Using the addition CONTEXT, for context-dependent BAdIs, an object reference variable con must be specified, the static type of which is, or includes, the tag interface IF_BADI_CONTEXT, and which contains a reference to a BAdI context object. If con is initial, an exception is raised. The addition CONTEXT cannot be entered for context-free BAdIs.

The addition CONTEXT controls the generation of the object plug-ins as follows:

If a BAdI implementation class implements multiple BAdI interfaces and GET BADI is executed within one internal session for several of these BAdIs, then multiple BAdI objects can point to the same object plug-in. This enables the sharing of data between different BAdIs. For context-free BAdIs, this is only the case for reuse. For context-dependent BAdIs, multiple BAdI objects from the same context can point to the same object plug-ins.

Notes

Exceptions

Catchable Exceptions

CX_BADI_CONTEXT_ERROR

CX_BADI_FILTER_ERROR

CX_BADI_INITIAL_CONTEXT

CX_BADI_MULTIPLY_IMPLEMENTED

CX_BADI_NOT_IMPLEMENTED

CX_BADI_UNKNOWN_ERROR