ABAP Keyword Documentation →  ABAP Programming Guidelines →  Structure and Style →  Alternative Spellings → 

Method Calls

Background

Static calls of methods can be formulated in two different ways. The obsolete long form

CALL METHOD meth EXPORTING ...

is based on the notation of the function module call. Alternatively, a short form can be used:

meth( ... ).
This form uses a parenthesis notation instead of the introductory ABAP words CALL METHOD. A combination of CALL METHOD and parentheses is also possible.

Rule

Formulate static method calls without CALL METHOD

Use the long form of the method call using CALL METHOD only for dynamic method calls.

Details

The short form of the static method call is clearer. The redundant ABAP words CALL METHOD provide no additional information to the reader. Using the short form, self-contained method calls have the same appearance as functional method calls on operand positions. For dynamic method calls, the long form with CALL METHOD is syntactically necessary. If it is only used there, the different notations provide the reader with another distinguishing feature between the static and dynamic method call.

Bad example

The following source code shows the long form of a static method call using CALL METHOD, which is no longer recommended.

...
CALL METHOD cl_class=>do_something
  EXPORTING
    some_input = value1
  IMPORTING
    some_output = value2
  CHANGING
    some_change = value3.
...

The following source code shows the same static method call as above, but with parentheses inserted. In this form, which is also syntactically correct, either CALL METHOD or the parentheses are superfluous.

...
CALL METHOD cl_class=>do_something(
  EXPORTING
    some_input = value1
  IMPORTING
    some_output = value2
  CHANGING
    some_change = value3 ).
...

Good example

The following source code shows the same method call as above, but as recommended, without CALL METHOD. If a method has only importing parameters, IMPORTING and CHANGING can be omitted, and also the EXPORTING addition. If it is a single importing parameter, its name can also be omitted.

...
cl_class=>do_something(
  EXPORTING
    some_input = value1
  IMPORTING
    some_output = value2
  CHANGING
    some_change = value3 ).
...