CALL FUNCTION


Variant 1

CALL FUNCTION func.

Additions



1. ... EXPORTING p1 = f1 ... pn = fn
2. ... IMPORTING p1 = f1 ... pn = fn
3. ... TABLES p1 = itab1 ... pn = itabn
4. ... CHANGING p1 = f1 ... pn = fn
5. ... EXCEPTIONS except1 = rc1 ... exceptn = rcn

Effect

Calls the function module func ; func can be a literal or a variable.
To edit function modules, select Tools -> ABAP/4 Workbench -> Function Library .
The assignment of parameters is by name ( p1 , p2 , etc.), not by sequence.
To return from the function module, you use the key word EXIT , unless EXIT occurs in a loop or a subroutine.

Note

You can use the editor commands " SHOW FUNCTION func " and " SHOW FUNCTION * " to get information about the function module func or any other function module.

Addition 1

... EXPORTING p1 = f1 ... pn = fn

Effect

EXPORTING passes fields, field strings or internal tables to the function module. You must declare the parameters p1 ... pn in the function interface as import parameters. When you call the function module, you must assign values to all import parameters which are not flagged in the interface definition as optional and do not have any default values.

Addition 2

... IMPORTING p1 = f1 ... pn = fn

Effect

IMPORTING passes fields, field strings or internal tables from the function module back to the calling program. The parameters p1 ... pn must be declared as export parameters in the function interface.

Addition 3

... TABLES p1 = itab1 ... pn = itabn

Effect

TABLES passes references to internal tables. The parameters p1 ... pn must be declared as table parameters in the function interface. When you call the function module, you must assign values to all table parameters which are not flagged as optional in the interface definition.

Addition 4

... CHANGING p1 = f1 ... pn = fn

Effect

CHANGING passes fields, field strings or internal tables to the function module and the changed values are returned. The parameters p1 ... pn must be declared as CHANGING parameters in the function interface. When you call the function module, you must assign values to all CHANGING parameters of the function module which are not flagged as optional in the interface definition and have no default values.

Addition 5

... EXCEPTIONS except1 = rc1 ... exceptn = rcn

Effect

EXCEPTIONS lists the exceptions to be handled by the calling program itself. At the end of the exception list, you can use OTHERS to refer to all the remaining exceptions.
If one of the listed exceptions occurs, SY-SUBRC is set to the appropriate value rc (a number literal!) and control passes back to the calling program. By specifying a return code, you can divided the exceptions into classes. With the second form, without "=rc", SY-SUBRC is set to a value other than 0 if an exception occurs.
If the function module triggers an exception (with the statements RAISE and MESSAGE ... RAISING ) and the exception is not to be handled by the calling program itself,

Note

The following EXCEPTIONS are predefined by the system and have a special meaning:

Examples

DATA: FIELD(30) VALUE 'Example: This is a field.', head(30). CALL FUNCTION 'STRING_SPLIT' EXPORTING DELIMITER = ':' STRING = FIELD IMPORTING HEAD = HEAD TAIL = FIELD EXCEPTIONS NOT_FOUND = 1 OTHERS = 2. CASE SY-SUBRC. WHEN 1. ... WHEN 2. .... ENDCASE. ... DATA: BEGIN OF TAB1 OCCURS 10, X, END OF TAB1, BEGIN OF TAB2 OCCURS 20, Y, END OF TAB2. CALL FUNCTION 'ITAB_COPY' TABLES TAB_IN = TAB1 TAB_OUT = TAB2.

Note

Runtime errors


Index
© SAP AG 1996