ABAP Keyword Documentation → ABAP − Reference → Calling and leaving program units → Calling Processing Blocks → Calling Procedures → Method Calls → Static Method Calls
meth( ... ) - Standalone Method Call
Other versions: 7.31 | 7.40 | 7.54
Syntax
{ meth( )
| meth( a )
| meth( p1 = a1 p2 = a2 ... )
| meth( [EXPORTING
p1 = a1 p2 = a2 ...]
[IMPORTING p1 = a1 p2 = a2 ...]
[CHANGING
p1 = a1 p2 = a2 ...]
[RECEIVING r = a]
[EXCEPTIONS [exc1 =n1 exc2 = n2 ...]
[OTHERS = n_others]] ) }.
Alternatives
1. meth( ).
2. meth( a ).
3. meth( p1 = a1 p2 = a2 ... ).
4. meth( EXPORTING ... IMPORTING ... CHANGING ... RECEIVING ... ).
Effect
Static call of a method specified as a standalone statement using the name meth
. The
parameter interface
of the method is filled with the actual parameters In the parentheses. In the first alternative, no
formal parameters are filled with actual parameters. The second and third alternatives are short forms
for methods where only the input parameters are filled with actual parameters. The fourth alternative
allows all possible formal parameters to be filled with actual parameters and non-class-based exceptions to be handled.
Note
The static method call described here is not to be confused with the call of static methods. A static method call is the static specification of an instance method or a static method. In addition, there is the dynamic method call, for which the methods are specified dynamically.
Alternative 1
meth( ).
Effect
Calls the method meth
without pass by parameter. The method can either have no input parameters or input/output parameters
or only optional input parameters or input/output parameters. Actual parameters are not assigned to any output parameters or to a return code.
Example
Calls a method without parameters.
CLASS c1 DEFINITION.
PUBLIC SECTION.
CLASS-METHODS do_something.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD do_something.
...
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
c1=>do_something( ).
Alternative 2
meth( a ).
Effect
This is the short form of the following:
meth( EXPORTING p = a ).
The method meth
can have the following parameters:
-
Either exactly one non-optional input parameter
p
and any number of optional input parameters -
Or only optional input parameters (of which
p
is defined as a preferred parameter usingPREFERRED PARAMETER
)
The value of a
is passed to the non-optional input parameter or to the preferred
parameter. The actual parameter a
can be specified as a data object, a function, or an expression.
The method can only have optional input/output parameters. No actual parameter is assigned to these input/output parameters, any output parameters, or return values.
Example
Calls a method with an input parameter.
CLASS c1 DEFINITION.
PUBLIC SECTION.
CLASS-METHODS do_something IMPORTING p TYPE i.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD do_something .
...
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
c1=>do_something( 333 ).
Alternative 3
meth( p1 = a1 p2 = a2 ... ).
Effect
This is the short form of the following:
meth( EXPORTING p1 = a1 p2 = a2 ... ).
The method meth
can have any number of input parameters p1
, p2
,
and so on, which are filled with the actual parameters a1
, a2
, and so on. The actual parameters can be specified as a data object, a function, or an expression.
The method can only have optional input/output parameters. No actual parameter is assigned to these input/output parameters, any output parameters, or return values.
Example
Calls a method with two input parameters.
CLASS c1 DEFINITION.
PUBLIC SECTION.
CLASS-METHODS do_something IMPORTING p1 TYPE i
p2 TYPE i.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD do_something .
...
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
c1=>do_something( p1 = 333 p2 = 444 ).
Alternative 4
meth( EXPORTING ... IMPORTING ... CHANGING ... RECEIVING ... ).
Effect
Calls the method meth
with explicit
pass by parameter and the option of handling non-class-based exceptions. This format can be used to call methods with any number of parameter interfaces.
Example
Calls a method with explicit pass by parameter.
CLASS c1 DEFINITION.
PUBLIC SECTION.
CLASS-METHODS do_something IMPORTING p1 TYPE i
p2 TYPE i
EXPORTING p3 TYPE i
p4 TYPE i
RETURNING VALUE(r) TYPE i.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD do_something .
...
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
c1=>do_something( EXPORTING p1 = 333
p2 = 444
IMPORTING p3 = DATA(a1)
p4 = DATA(a2)
RECEIVING r = DATA(a3) ).