Ansicht
Dokumentation

ABAPCALL_FUNCTION_PARAMETER - CALL FUNCTION PARAMETER

ABAPCALL_FUNCTION_PARAMETER - CALL FUNCTION PARAMETER

BAL Application Log Documentation   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.
SAP E-Book

CALL FUNCTION, parameter_list

Short Reference



... $[EXPORTING  p1 = a1 p2 = a2 ...$]
    $[IMPORTING  p1 = a1 p2 = a2 ...$]
    $[TABLES     t1 = itab1 t2 = itab2 ...$]
    $[CHANGING   p1 = a1 p2 = a2 ...$]
    $[EXCEPTIONS $[exc1 = n1 exc2 = n2 ...$]
                $[error_message = n_error$]
               $[OTHERS = n_others$]$].

Additions

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

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

3. ... TABLES t1 = itab1 t2 = itab2 ...

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

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

6. ... EXCEPTIONS ... error_message = n_error ...

Effect

With the exception of the addition EXCEPTIONS, these additions assign the actual parameters a1, a2, ... to the formal parameters p1, p2, ... or t1, t2, ... of the called function module. All data objects and some expressions whose data type matches the typing of the corresponding formal parameter can be specified as actual parameters. With the exception of calculation expressions specified for input parameters, each formal parameter inherits all properties of the assigned actual parameter when called. Non-class-based exceptions can be handled using the addition EXCEPTIONS. The order of the additions is predefined.

A catchable exception is raised whenever a formal parameter is incorrect, and the name of the function module is specified by a constant or as a character literal. Unlike method calls, formal parameters are not checked by the syntax check. A static check only takes place in the extended program check. If the name of the function module is specified by a variable, the specification of an incorrect formal parameter is ignored at runtime.

Notes

  • The formal parameters and non-class-based exceptions of a function module are defined as its parameter interface in the Function Builder.

Addition 1

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

Effect

This addition assigns actual parameters to the input parameters of the called function module. EXPORTING can be used to assign actual parameters to the optional input parameters but is mandatory for non-optional input parameters. In pass by reference, a reference to an actual parameter is passed when the call is made. In pass by value, the content of an actual parameter is assigned to the corresponding formal parameter.

a1, a2, ... are general expression positions, which means that, in addition to data objects, functions and expressions can also be passed as actual parameters. Special rules apply in this case.

Notes

  • Substring access is not possible on an actual parameter of type string or xstring specified after EXPORTING.
  • Unlike in method calls, a generic type specification # is not possible when a constructor expression is specified. This is because the typing of the parameters is not determined until runtime.

Addition 2

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

Effect

This addition assigns actual parameters to the output parameters of the called function module. IMPORTING can be used to assign actual parameters to all output parameters, but this is not mandatory. 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 relevant actual parameter only if the function module is completed without errors.

Note

Unlike in method calls, no writable expressions and no inline declarations can be specified.

Addition 3

... TABLES t1 = itab1 t2 = itab2 ...

Effect

This addition assigns actual parameters to the table parameters of the called function module. If TABLES is used, internal tables itab1, itab2, ... must be assigned to all non-optional table parameters t1, t2, ... of the called function module and are optional for all optional table parameters. For itab1, itab2, ..., only standard tables can be specified. The data is passed using a reference
(except RFC). If a specified table itab1, itab2, ... has a header line, this is also passed. Otherwise, the header line of the corresponding table parameter t1, t2, ... is initial after the call.

Addition 4

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

Effect

This addition assigns actual parameters to the input/output parameters of the called function module. CHANGING can be used to assign actual parameters to the optional input/output parameters but is mandatory for non-optional input/output parameters. In pass by reference, a reference to an actual parameter is passed when the call is made. In pass by value, the content of an actual parameter is assigned to the relevant formal parameter and the modified content of an input/output parameter is only assigned to the relevant actual parameter if the function module is completed without errors.

Note

Unlike in method calls, no writable expressions can be specified.

Addition 5

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

Effect

During program execution, a specified exception is not checked when a function module is called. Only the extended program check reports whether a specified exception is not declared in its interface.

Notes

  • For the addition EXCEPTIONS, CALL FUNCTION also has an obsolete short form, in which the specification of the return value = n can also be omitted after a specified exception. If an exception is raised, the value 1 is assigned to sy-subrc implicitly. The return code must always be specified explicitly, however.
  • 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 function module, no runtime error occurs, but the exception cannot be handled.

Addition 6

... EXCEPTIONS ... error_message = n_error ...

Effect

Specifying the predefined exception error_message after EXCEPTIONS changes the processing of all messages that are sent as follows during function module processing:

  • Messages sent using the statement MESSAGE without the addition RAISING.
  • Messages sent using the statement MESSAGE RAISING because no return code is assigned to them.
  • Messages sent by the ABAP runtime framework.

For these cases, message processing is affected as follows:

  • Messages of the type E and A raise the exception error_message and set sy-subrc to n_error. The message class, message type, message number, and the content of possible placeholders for the MESSAGE statement are available in the fields sy-msgid, sy-msgno, sy-msgty, and sy-msgv1, ... sy-msgv4. In the case of messages of type A, the statement ROLLBACK WORK is also executed implicitly. For more information about behavior in background processing, see messages in background processing.
  • Messages of the type X are not affected. As always, they cause a program termination with a short dump.

Notes

  • When messages are handled with the predefined exception error_message, it does not matter whether the message was sent in the current function module or in a module that is called by it. Unlike the exceptions raised by the statement RAISE, messages sent using the statement MESSAGE are propagated across call levels.
  • Only messages from the current internal session are handled. Messages from programs called when the function module is processed are not handled.
  • The following situations can arise for the statement MESSAGE RAISING within the called function module:
  • If a return code is assigned to the exception specified after RAISING, the exception is handled independently of error_message and sy-subrc is set to this value.

  • If no return code is assigned to the exception specified after RAISING and error_message is specified, the sent message is affected as specified above.

  • If no return code is assigned to the exception specified after RAISING and error_message is not specified, the message is sent in accordance with its type.

  • When a program is resumed after handling a type A message, it must be ensured that a complete ROLLBACK WORK has been performed and not just a database rollback.
  • When programs are executed, the ABAP runtime framework can also send messages, for example, during automatic checks on dynpros. These messages are caught using error_message in the same way as messages sent using MESSAGE.

Example

Call of the function module GUI_DOWNLOAD to store the content of an internal table in a file on the current presentation server. The name of the function module is specified as a character literal, which is the most frequent type of specification in static parameter assignment.








CPI1466 during Backup   ABAP Short Reference  
This documentation is copyright by SAP AG.

Length: 16696 Date: 20240424 Time: 185423     sap01-206 ( 224 ms )