SAP CALL METHOD METH IDENT DYNA ABAP Statements



Get Example source ABAP code based on a different SAP table
  



CALL METHOD, dynamic_meth
Short Reference

ABAP_SYNTAX
... (meth_name)
$| oref->(meth_name)
$| class=>(meth_name)
$| (class_name)=>(meth_name)
$| (class_name)=>meth ...

ABAP Addition
1 ... (meth_name) ...
2 ... (class_name) ...

ABAP_ALTERNATIVES:
1 ... (meth_name) ...
2 ... oref->(meth_name) ...
3 ... class=>(meth_name) ...
4 ... (class_name)=>(meth_name) ...
5 ... (class_name)=>meth ...

What does it do?
These names are used to specify methods dynamically.

ABAP Addition
BEGIN_SECTION ID CALL-METHOD-DYNAMIC-METHOD

What does it do?
meth_name expects a character-like field that must contain the name of a method when the statement is executed.
END_SECTION ID CALL-METHOD-DYNAMIC-METHOD

ABAP Addition

What does it do?
class_name expects a character-like field that must contain the name of a class in uppercase letters when the statement is executed. An absolute type name can also be specified. The following can be specified for class_name:
Literal or constants If the data object class_name is specified as a character literal or as a constant, it can be evaluated statically, and the specified class is recognized as the used object.
Variable
BEGIN_SECTION ID CALL-METHOD-DYNAMIC-CLASS If the data object class_name is specified as a variable, it is specified only dynamically, and the content is not evaluated statically.
END_SECTION ID CALL-METHOD-DYNAMIC-CLASS
When the statement is executed, class_name is not evaluated until runtime (in both cases).

ABAP Alternative 1 ... (meth_name) ...

What does it do?
This variant is only possible for methods of the same class. It works like me->(meth_name) (see alternative 2).

ABAP Alternative 2 ... oref->(meth_name) ...
BEGIN_SECTION ID CALL-METHOD-DYNAMIC-REF

What does it do?
This form is possible for all visible methods of objects. oref can be any class reference variable or interface reference variable that points to an object containing the method or interface method specified in meth_name. The system first searches in the static type and then in the dynamic type of oref for the method.



Latest notes:

In dynamic access as in static access, interface reference variables cannot be used to access any components, only interface components.
NON_V5_HINTS
The pseudo reference super cannot be used in a dynamic method call.
ABAP_HINT_END
END_SECTION ID CALL-METHOD-DYNAMIC-REF

ABAP Alternative 3 ... class=>(meth_name) ...

ABAP Alternative 4 ... (class_name)=>(meth_name) ...

ABAP Alternative 5 ... (class_name)=>meth ...

What does it do?
These forms are possible for all visible static methods. Both the class and method can be specified dynamically. The class class and the method meth can also be specified directly.
For alternatives with a dynamic class specification (class_name), the system first searches the class and then the method. If class is specified statically, the search for the method is carried out in the existing class.



Latest notes:

Methods of local classes can be called externally only by specifying the compilation unit. In the case of