ABAP Keyword Documentation → ABAP - Reference → Calling and leaving program units → Calling Processing Blocks → Calling procedures → CALL FUNCTION → CALL FUNCTION func
Calling Function Modules
The example demonstrates how a function module can be called.
Other versions: 7.31 | 7.40 | 7.54
Source Code
REPORT demo_mod_tech_fb_read_spfli.
PARAMETERS carrier TYPE s_carr_id DEFAULT 'LH'.
DATA: jtab TYPE spfli_tab,
wa LIKE LINE OF jtab.
CALL FUNCTION 'READ_SPFLI_INTO_TABLE'
EXPORTING
id = carrier
IMPORTING
itab = jtab
EXCEPTIONS
not_found = 1
OTHERS = 2.
CASE sy-subrc.
WHEN 1.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
WHEN 2.
MESSAGE e888(sabapdemos) with 'Error in function module'.
ENDCASE.
LOOP AT jtab INTO wa.
WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
ENDLOOP.
Description
The function module READ_SPFLI_INTO_TABLE reads all data from the database
table SPFLI where the key field CARRID matches the import parameter
id and passes this data into the internal table spfli_tab
. If no such
data can be found, the exception NOT_FOUND is raised using
MESSAGE ... RAISING. Otherwise, the table is passed to the caller as an export parameter.
The actual parameters carrier
and jtab
in the
above program have the same data types as the corresponding interface parameters of the function module.
The exception NOT_FOUND is handled, but the message sent is the same as sent by the function module if the exception were not handled.