sapdev logo background
sapdev logo sapdev logo
Comments

ABAP CALL FUNCTION PARAMETER Statement syntax, information and example SAP source code



Return to Statement index



CALL FUNCTION - parameter_list

Short Reference

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

ABAP_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 ...

What does it do? With the exception of the EXCEPTIONS addition, these additions assign the actual parameters a1 , a2 , ... to the formal parameters p1 , p2 , ... or t1 , t2
, ... of the parameter interface of the function module in func
. All data objects whose data type matches the typing of the appropriate formal parameter can be specified as actual parameters. Each formal parameter assumes all the properties of the actual parameter assigned to it when it is called. Non-class-based exceptions can be handled using the addition
EXCEPTIONS . The order of the additions is fixed.
A handleable 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 in method calls, static checks are performed only by the extended program check and not by the syntax check. If the name of the function module is specified by a variable, the specification of an incorrect formal parameter is ignored at runtime.

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

What does it do? The addition EXPORTING assigns actual parameters to the input parameters of the called function module. The syntax and semantics of these additions are the same as in method calls .
a1 , a2 , ... are
general expression positions . In other words, functions and expressions can be passed as actual parameters, alongside data objects. Special rules apply in this case. Unlike in method calls, types cannot be specified generically ( # ) when a
constructor expression is specified. This is because the typing of the parameters is not determined until runtime.
Latest notes: No substring access is possible after an actual parameter of type string or xstring specified after EXPORTING .

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

What does it do? The addition IMPORTING assigns actual parameters to the output parameters of the called function module. The syntax and meaning of this addition are the same as in method calls , but it is not possible to specify writable expressions .

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

What does it do? With the addition TABLES , internal tables
itab1 , itab2 , ... must be assigned to all non-optional table parameters t1 , t2 , ... of the called function module. For itab1 , itab2 , ... , only
standard tables can be specified. The data is passed using a reference (with the exception of 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.

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

What does it do? The addition CHANGING assigns actual parameters to the input/output parameters of the called function module. The syntax and semantics of these additions are the same as in method calls .

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

What does it do?
When a function module is called, the extended program check responds only if a specified exception is not declared in its interface. This is not checked while the program is being executed.
Latest notes: For the addition EXCEPTIONS . CALL FUNCTION also has an obsolete short form
in which the return code = n can 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.

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

What does it do? If the predefined exception error_message is specified after EXCEPTIONS , all messages
that are sent using the statement MESSAGE without the addition RAISING ,
that are sent using the statement MESSAGE RAISING because no return code is assigned to them,
that are sent by the ABAP runtime environment
during function module processing are affected as follows:
Messages of the type S, I, or W are not sent but are flagged in the log in
background processing .

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 contents of possible placeholders for the MESSAGE statement are in the fields sy-msgid , sy-msgno
, sy-msgty , and sy-msgv1 , ... sy-msgv4 . With messages of the type A, the ROLLBACK WORK statement is also executed explicitly. For 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 .

Latest notes: When handling messages with the predefined exception
error_message , it does not make a difference whether the message is sent in the current function module or in a module that is called by this function module. Unlike the exceptions raised by the statement RAISE , messages sent using the statement MESSAGE are propagated across calling levels.

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 continuing with a program after handling a type A message, note that a complete ROLLBACK WORK was carried out, and not just a database rollback.

    When programs are executed, the ABAP runtime environment can also send messages, for example when the automatic checks on screen input are performed. These messages are caught using error_message in the same way as messages sent using MESSAGE .

    Example ABAP Coding Calling the function module GUI_DOWNLOAD for saving the content of an internal table to a file on the current presentation server . The name of the function module is specified as an untyped character literal, which is the most frequent type of specification in static parameter assignment.
    CONSTANTS path TYPE string VALUE `c:\temp\`.

    DATA: line TYPE c LENGTH 80,
    text_tab LIKE STANDARD TABLE OF line,
    fleng TYPE i.

    ...

    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename = path <(> <)><(> <)> `text.txt`
    filetype = 'ASC'
    IMPORTING
    filelength = fleng
    TABLES
    data_tab = text_tab
    EXCEPTIONS
    file_write_error = 1
    invalid_type = 2
    no_authority = 3
    unknown_error = 4
    OTHERS = 10.

    CASE sy-subrc.
    WHEN 1.
    ...
    ...
    ENDCASE.
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    CALL_FUNCTION_GENERAL
    CALL_FUNCTION_REMOTE_TASK




    comments powered by Disqus