Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Calling and leaving program units →  Calling Processing Blocks →  Calling Procedures →  Method Calls →  Dynamic Method Call →  CALL METHOD 

CALL METHOD - dynamic_meth

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... (meth_name) 
  | cref->(meth_name)
  | iref->(meth_name)
  | (class_name)=>(meth_name)
  | (class_name)=>meth
  | class=>(meth_name) ...

Alternatives

1. ... (meth_name) ...

2. ... cref->(meth_name) ...

3. ... iref->(meth_name) ...

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

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

6. ... class=>(meth_name) ...

Effect

These names are used to specify methods dynamically. meth_name and class_name expect character-like fields, which must contain the name of a method or a class in uppercase when the statement is executed. For class_name, an absolute type name can also be specified.

Alternative 1

... (meth_name) ...

Effect

This variant is only possible for methods of the same class. It has the same effect as me->(meth_name) (see alternative 2).

Alternative 2

... cref->(meth_name) ...

Effect

This form is possible for all visible methods of objects. cref can be any class reference variable that points to an object that contains the method specified in meth_name. This method is searched for first in the static type, then in the dynamic type of cref

Alternative 3

... iref->(meth_name) ...

Effect

This form is possible for all visible interface methods of objects. iref can be any interface reference variable that points to an object that contains the interface method specified in meth_name. The search for this method takes place only in the static type of iref.


Note

Unlike access using class reference variables, interface reference variables can only be used to access interface components, not all components (even dynamically).

Alternative 4

... (class_name)=>(meth_name) ...

Alternative 5

... (class_name)=>meth ...

Alternative 6

... class=>(meth_name) ...

Effect

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.

In the alternatives with a dynamic class name (class_name), first the class is searched for, then the method. If class is specified statically, the search for the method is carried out in the existing class.


Notes

  • If, in class_name, a class of another program is specified using an absolute type name, this program is loaded into a new additional program group or into the current program group, depending on the program type (if not already loaded). If required, the program constructor is also executed.
  • The external calling of local class methods is critical, especially for executable programs, module pools, and subroutine pools, since it can usually not be determined statically which program group the framework group is assigned to.