ABAP Keyword Documentation → ABAP − Reference → Enhancements → Enhancements Using BAdIs
CALL BADI
Other versions: 7.31 | 7.40 | 7.54
Syntax
CALL BADI { badi->meth parameter_list }
| { badi->(meth_name) {parameter_list
|
parameter_tables} }.
Effect
Calls a BAdI method. The statement has a static and a dynamic variant. In both variants a
BAdI reference variable must be specified for badi
.
-
In the static variant, a BAdI reference variable of the static type of a concrete
BAdI class must be specified for
badi
, and formeth
a BAdI method of the corresponding BAdI must be entered directly. -
In the dynamic variant, a
BAdI reference variable of the static type of the abstract superclass CL_BADI_BASE must be specified
for
badi
. Formeth_name
, a character-like data object must be specified that must contain the name of a BAdI method in uppercase when the statement is executed.
With respect to the addressing of BAdI methods, the BAdI reference variable behaves like an interface reference variable with the static type of the affected BAdI interface. A BAdI method declared as a component of the corresponding BAdI interface is addressed directly using its name. BAdI methods declared in component interfaces of the BAdI interface can be addressed using the interface component selector or any alias names.
The additions parameter_list
or
parameter_tables assign actual parameters to the formal parameters of the BAdI method or handle non-class-based exceptions exactly as described in
Method Call. The exceptions that can occur in dynamic
accesses are also the same as those of CALL METHOD
.
The statement CALL BADI
dictates that the specified method is called in all
object plug-ins to which the
BAdI object referenced by the badi
refers.
-
If the BAdI is defined for single use,
badi
must contain a valid BAdI reference for a static BAdI call. Ifbadi
is initial, a handleable exception is raised. -
If the BAdI is defined for multiple use,
badi
must contain a valid BAdI reference or can be initial for a static BAdI call. If the referenced BAdI object refers to multiple object plug-ins ,the call order is the same for everyCALL BADI
statement. The exact call order can be determined in the definition of the associated BAdI implementations, if the predefined BAdI BADI_SORTER of the enhancement spot of the same name was implemented for the current BAdI. If the referenced BAdI object does not reference object plug-ins, or thebadi
is initial, the statement is ignored. -
In a dynamic BAdI call, a handleable exception is always raised if there is an invalid BAdI reference in
badi
.
If a method is added to a BAdI afterwards, it can be missing in a BAdI implementation. In this case
the call is executed as if the method existed with an empty implementation. Actual parameters that are
bound to EXPORTING
or RETURNING
parameters passed by value are initialized. All other actual parameters remain unchanged.
System Fields
With a regular method call, the system field sy-subrc
is either set to 0
or, when handling non-class-based exceptions, it is set to the value specified after EXCEPTIONS
.
Notes
-
BAdI objects and BAdI references can only be created using the statement
GET BADI
. -
In the terminology of the enhancement concept, the statement
CALL BADI
is known as an enhancement spot element invocation. -
The call of a BAdI method of a BAdI defined for single use behaves like a method call with meth(
...): the called method must exist. In contrast, calls of a BAdI method defined for multiple
use are more similar to the raising of an event using
RAISE EVENT
: One or more methods can exist, or no methods at all. -
The addition
DEFAULT
can be used when defining a BAdI method in a BAdI interface to define the behavior for methods that are not implemented.
Exceptions
Handleable Exceptions
CX_BADI_INITIAL_REFERENCE
-
Cause: The reference variable
badi
is initial either for the static call, although the BAdI was defined for single use, or for the dynamic call.
CX_SY_DYN_CALL_ILLEGAL_METHOD
-
Cause: Method does not exist at the dynamic call
Runtime error:DYN_CALL_METH_NOT_FOUND