CALL FUNCTION - parameter_tables

Syntax

... [PARAMETER-TABLE ptab]
    [EXCEPTION-TABLE etab]... .

Extras:

1. ... PARAMETER-TABLE ptab ...

2. ... EXCEPTION-TABLE etab ...

Effect

These additions assign actual parameters to the formal parameters of the function module and return values to the non-class-based exceptions - with the help of the internal tables ptab and etab.

Addition 1

... PARAMETER-TABLE ptab ...

Effect

Using PARAMETER-TABLE, actual parameters can be assigned to all the formal parameters of the called function module. For ptab, a sorted table of the table type ABAP_FUNC_PARMBIND_TAB or of the line type ABAP_FUNC_PARMBIND from the ABAP type group must be specifid. The table must be specified for the execution of the CALL FUNCTION statement for each non-optional formal parameter and can contain exactly one line for each optional formal parameter. The columns of the table are:

- ABAP_FUNC_EXPORTING for input parameters
- ABAP_FUNC_IMPORTING for output parameters
- ABAP_FUNC_CHANGING for input/output parameters
- ABAP_FUNC_TABLES for table parameters

If the type specified from the caller perspective does not match the actual type of the formal parameter, an exception is raised, which can be handled.

The columns NAME and KIND form the unique key of the table ptab.

Addition 2

... EXCEPTION-TABLE etab ...

Effect

Using EXCEPTION-TABLE, return values can be assigned to exceptions of the called function module that are not marked as exception classes in the Function Builder. For etab, a hash table of the table type ABAP_FUNC_EXCPBIND_TAB or of the line type ABAP_FUNC_EXCPBIND from the ABAP type group must be specified. The table can contain exactly one line for each non-class-based exception of the function module during the execution of the CALL FUNCTION statement. The columns of the table are:

The column NAME is the unique key for the table etab.

Example

Call of the function module GUI_DOWNLOAD with dynamic parameter transfer. The name of the function module is specified in the funct string and the interface is supplied with data through the internal tables ptab and etab.

TYPE-POOLS abap.

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

DATA: func TYPE string,
      ptab TYPE abap_func_parmbind_tab,
      ptab_line TYPE abap_func_parmbind,
      etab TYPE abap_func_excpbind_tab,
      etab_line TYPE abap_func_excpbind.

func = 'GUI_DOWNLOAD'.
filename = 'c:\temp\text.txt'.
filetype = 'ASC'.

ptab_line-name = 'FILENAME'.
ptab_line-kind = abap_func_exporting.
GET REFERENCE OF filename INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.

ptab_line-name = 'FILETYPE'.
ptab_line-kind = abap_func_exporting.
GET REFERENCE OF filetype INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.

ptab_line-name = 'DATA_TAB'.
ptab_line-kind = abap_func_tables.
GET REFERENCE OF text_tab INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.

ptab_line-name = 'FILELENGTH'.
ptab_line-kind = abap_func_importing.
GET REFERENCE OF fleng INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.

...

etab_line-name = 'OTHERS'.
etab_line-value = 10.
INSERT etab_line INTO TABLE etab.

CALL FUNCTION func
  PARAMETER-TABLE
    ptab
  EXCEPTION-TABLE
    etab.

CASE sy-subrc.
  WHEN 1.
    ...
  ...
ENDCASE.