sapdev logo background
sapdev logo sapdev logo
Comments

ABAP FUNCTION Statement syntax, information and example SAP source code



Return to Statement index



FUNCTION

Short Reference

ABAP Syntax FUNCTION func.
*"---------------------------------------------------------
*" Local Interface:
*" parameter_interface
*"---------------------------------------------------------
...
ENDFUNCTION.

What does it do? 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 .

Latest notes: 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 ABAP Coding Implementation of 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 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.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




FROM_CLAUSE
FUNCTION-POOL




comments powered by Disqus