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 Function Builder is automatically displayed as parameter_interface in comment lines underneath the statement FUNCTION.

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 predicate expression IS SUPPLIED can be used in the function module to determine whether an actual parameter has been specified for a formal parameter.


Example

Implements a function module that reads data in a table-like formal parameter flight_tab under the condition of an elementary formal parameter id. The parameter interface defined in 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
         WHERE carrid = @id
         INTO TABLE @flight_tab.
ENDFUNCTION.

Continue

Function Module Interface