ABAP Keyword Documentation → ABAP − Reference → Calling and leaving program units → Calling Processing Blocks → Calling Procedures → CALL FUNCTION
CALL FUNCTION - parameter_tables
Other versions: 7.31 | 7.40 | 7.54
Syntax
... [PARAMETER-TABLE ptab]
[EXCEPTION-TABLE etab] ...
Extras
1. ... PARAMETER-TABLE ptab ...
2. ... EXCEPTION-TABLE etab ...
Effect
These additions use the special internal tables ptab
and etab
to assign actual parameters to the formal parameters of the function module and to assign return values to the non-class-based exceptions.
Addition 1
... PARAMETER-TABLE ptab ...
Effect
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:
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 the 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 pointed to by the reference variable in TABLES_WA is passed to the header line of the table parameter specified in NAME.
Together, the columns NAME and KIND are the unique key of the table ptab
.
Addition 2
... EXCEPTION-TABLE etab ...
Effect
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
Specifies the name of the exception orerror_message
in question or specifiesOTHERS
in uppercase. -
VALUE of type
i
Specifies the number value that is available insy-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
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:\temp\text.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.