Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Calling and leaving program units →  Calling Processing Blocks →  Calling procedures →  CALL METHOD 

CALL METHOD - parameter_list

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


...    [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] ].

Extras

1. ... EXPORTING p1 = a1 p2 = a2 ...

2. ... IMPORTING p1 = a1 p2 = a2 ...

3. ... CHANGING p1 = a1 p2 = a2 ...

4. ... RECEIVING r = a

5. ... EXCEPTIONS exc1 = n1 exc2 = n2 ... [OTHERS = n_others]

Effect

With the exception of addition EXCEPTIONS, these additions assign actual parameters a1 a2... to the formal parameters p1 p2 ... or r of the parameter interface of method meth. All data objects with a data type that matches the typing of the corresponding formal parameter according to the rules of the typing check can be specified as actual parameters. Functions and expressions can also be passed to input parameters as actual parameters.

With the exception of the return code r for functional methods and arithmetic expressions for input parameters, every formal parameter assumes all attributes of the assigned actual parameters when called. Non-class-based exceptions can be handled using the addition EXCEPTIONS. The order of the additions is fixed.

Unlike function module calls, static parameter passes are checked by the synax check and not just by the extended program check.

Addition 1

... EXPORTING p1 = a1 p2 = a2 ...

Effect

If non-optional input parameters are defined for the called method in statement METHODS or CLASS-METHODS after IMPORTING, actual parameters must be assigned to these using EXPORTING. Actual parameters can be assigned to optional input parameters. When called, either a reference to an actual parameter is passed, or the content of an actual parameter is assigned to the relevant formal parameter, depending on the passing type.

If functions and expression as actual parameters are specified for input parameters, special rules apply.


Note

In particular, specifying arithmetic expressions as actual parameters entails the use of functional methods.

Addition 2

... IMPORTING p1 = a1 p2 = a2 ...

Effect

If output parameters are defined for the called method in statement METHODS or CLASS-METHODS after EXPORTING, actual parameters can be assigned to these using IMPORTING. In pass-by-reference, a reference is passed to an actual parameter when the call is made. In pass-by-value, the content of an output parameter is assigned to the actual parameter in question only if the method is completed without errors.

Addition 3

... CHANGING p1 = a1 p2 = a2 ...

Effect

If non-optional input/output parameters are defined for the called method in statement METHODS or CLASS-METHODS after CHANGING, actual parameters must be assigned to these using CHANGING. Actual parameters can be assigned to optional input/output parameters. When called, either a reference to an actual parameter is passed, or the content of an actual parameter is assigned to the relevant formal parameter, depending on the passing type. In pass-by-value, the content of an input/output parameter is assigned to the actual parameter in question only if the method is completed without errors.

Addition 4

... RECEIVING r = a

Effect

If a return code is defined for the called method in METHODS or CLASS-METHODS after RETURNING, an actual parameter can be assigned to this using RECEIVING. The data type of the actual parameter does not have to comply with the general rules of the typing check; it is sufficient if the return code can be converted to the actual parameter in accordance with the conversion rules.

If the method ends without errors, the content of the formal parameter is assigned to the actual parameter. The content is converted if necessary.


Note

A functional method with a return code is not usually called with CALL METHOD, but in operand positions.

Addition 5

... EXCEPTIONS exc1 = n1 exc2 = n2 ...  [OTHERS = n_others]

Effect

This addition can only be used in standalone method calls and not in function calls.

You can use EXCEPTIONS to assign return values to non-class-based exceptions exc1 exc2 ... declared in the parameter interface. Each exception exc1 exc2 ... that the caller wants to handle must be assigned to a directly specified number n1 n2 .... You can specify all numbers between 0 and 65535. The behavior outside of this range is undefined.

By specifying OTHERS as the last item after EXCEPTIONS, you can assign all exceptions not listed explicitly in exc1 exc2... a common return code, by assigning a number n_others. You can assign the same return code to different exceptions (including OTHERS). The behavior when an exception is raised is as follows:

  • If the statement RAISE or MESSAGE RAISING is used to raise an exception exc1 exc2 ... (to which a return code is assigned) the procedure is ended immediately, any output parameters or return values passed by value are canceled, and the number n1 n2 ... assigned to the exception is available to be evaluated in sy-subrc .
  • If the call of an exception raised by RAISE does not assign a return value, the program terminates with a runtime error.
  • If the call of an exception raised by MESSAGE RAISING does not assign a return value, the message is sent and the system continues in accordance with the message type.

If no exception is raised, a call sets sy-subrc to 0.

If class-based exceptions are declared in the parameter interface, the addition EXCEPTIONS cannot be specified in the call.

The specified exceptions must be present in the parameter interface of the method.


Note

If the value 0 is assigned to an exception, this indicates that the caller wants to ignore this exception. If the exception is raised in the method, no runtime error occurs, but the exception cannot be handled.