SAP CALL FUNCTION DYNAMIC ABAP Statements

Get Example source ABAP code based on a different SAP table
  



CALL FUNCTION - parameter_tables

Short Reference


ABAP Syntax ABAP_KEY ... [PARAMETER-TABLE ptab]

[EXCEPTION-TABLE etab]... .

ABAP Addition
1 ... PARAMETER-TABLE ptab ...
2 ... EXCEPTION-TABLE etab ...

What does it do? These additions use the special internal tables ptab and etab to assign actual parameters to the formal parameters of the function module and return values to the non-class-based exceptions.
• PARAMETER-TABLE CALL FUNCTION

ABAP Addition

What does it do? PARAMETER-TABLE can be used to assign actual parameters to all formal parameters of the called function module. ptab expects a sorted table of table type ABAP_FUNC_PARMBIND_TAB or of row type ABAP_FUNC_PARMBIND from the type group ABAP. When the statement CALL FUNCTION is executed, the table must contain exactly one row for each non-optional formal parameter; this row is optional for each optional formal parameter. The table columns are: NAME of type c and length 30
for the name of the corresponding formal parameter in uppercase letters. If a nonexistent formal parameter is specified, a handleable exception is raised.
KIND of type i
for the category of the formal parameter. KIND must have the value of one of the following constants of the type group ABAP: - ABAP_FUNC_EXPORTING for input parameters
- ABAP_FUNC_IMPORTING for output parameters
- ABAP_FUNC_TABLES for table parameters
- ABAP_FUNC_CHANGING for input/output parameters

If the category specified from the caller perspective does not match the actual category of the formal parameter, a handleable exception is raised.
VALUE of type REF TO data
as a pointer to an appropriate actual parameter. The data object to which the reference variable in VALUE points is assigned to the formal parameter specified in NAME.
TABLES_WA of type REF TO data
as a pointer to a suitable work area if the column KIND contains the value ABAP_FUNC_TABLES. If TABLES_WA is not initial, the data object to which the reference variable in TABLES_WA points is passed to the header line of the table parameter specified in NAME.

The columns NAME and KIND form the unique key of the table ptab.
• EXCEPTION-TABLE CALL FUNCTION

ABAP Addition

What does it do? EXCEPTION-TABLE can be used to assign return values to exceptions of the called function module that are not marked as exception classes in Function Builder. etab expects a hashed table of table type ABAP_FUNC_EXCPBIND_TAB or of row type ABAP_FUNC_EXCPBIND from the type group ABAP. The table can contain exactly one row for each non-class-based exception of the function module when the statement CALL FUNCTION is executed. The table columns are: NAME of type c and length 30
for the name of the corresponding exception or error_message, or OTHERS in uppercase letters.
VALUE of type i
for the numeric value that is available in sy-subrc after the exception specified in NAME is handled
MESSAGE of type REF TO data
(not currently used)

The column NAME is the unique key of table etab.



Example ABAP Coding
Calls the function module GUI_DOWNLOAD with
dynamic pass by parameter The name of the function module is specified in the string func and the interface is supplied with data using the internal tables ptab and etab. DATA: line TYPE c LENGTH 80,
text_tab LIKE STANDARD TABLE OF line,
filename TYPE string,
filetype TYPE c LENGTH 10,
fleng TYPE i.

DATA: func TYPE string,
ptab TYPE abap_func_parmbind_tab,
etab TYPE abap_func_excpbind_tab.

func = 'GUI_DOWNLOAD'.
filename = 'c: emp ext.txt'.
filetype = 'ASC'.

ptab = VALUE #( ( name = 'FILENAME'
kind = abap_func_exporting
value = REF #( filename ) )
( name = 'FILETYPE'
kind = abap_func_exporting
value = REF #( filetype ) )
( name = 'DATA_TAB'
kind = abap_func_tables
value = REF #( text_tab ) )
( name = 'FILELENGTH'
kind = abap_func_importing
value = REF #( fleng ) ) ).

etab = VALUE #( ( name = 'OTHERS' value = 10 ) ).

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

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

Return to menu