Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Program structure →  Modularization Statements →  Procedures →  Function Modules 

FUNCTION

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


FUNCTION func. 
"---------------------------------------------------------
" Local Interface:
" parameter_interface
"---------------------------------------------------------
  ...
ENDFUNCTION.

Effect

Between the statements FUNCTION and ENDFUNCTION, the functions of a function module func are implemented in a function group. The function module and its interface are defined in the Function Builder tool. In the source code of the function module, the function module interface defined in the Function Builder is automatically displayed as parameter_interface in comment lines underneath the FUNCTION statement.

Within the function module, local data types and data objects can be declared. There is also access to the formal parameters of the function module and to the global data types and data objects of the function group. A function module is called using the statement CALL FUNCTION.


Note

The logical expression IS SUPPLIED can be used in the function module to determine whether an actual parameter has been specified for a formal parameter.


Example

Implementation of a function module that reads data in a table-type formal parameter flight_tab under the condition of an elementary formal parameter id. The parameter interface defined in the Function Builder is visible as a comment.

FUNCTION read_spfli_into_table.
"---------------------------------------------------------
*" Local Interface:
"       IMPORTING
"             VALUE(ID) LIKE  SPFLI-CARRID DEFAULT 'LH '
"       EXPORTING
*"             FLIGHT_TAB TYPE  SPFLI_TAB
*"---------------------------------------------------------
  SELECT *
         FROM spfli
         INTO TABLE flight_tab
         WHERE carrid = id.
ENDFUNCTION.

Continue

Function Module Interface