CALL FUNCTION

CALL FUNCTION

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 (static call) or a variable (dynamic call).
The name of the function module must be uppercase.
To edit function modules, choose
Tools -> ABAP Workbench -> Function Builder.
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.

Notes

You can use a namespace prefix with function modules.
You can insert a function call in the
ABAP Editor by choosing Pattern and entering a function func in the CALL FUNCTION field. The additions for the function are automatically included as well as the function call itself. 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.

to the calling program. The parameters p1 ... pn must be declared as export parameters in the function interface.

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.

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 numeric 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

TABLES SFLIGHT. 
DATA: P_LOSS LIKE SFLIGHT-PAYMENTSUM, 
	P_REVENUE LIKE SFLIGHT-PRICE. 
SELECT * FROM SFLIGHT WHERE... . 
 CALL FUNCTION 'CALCULATE_REVENUE_LOSS' 
	 EXPORTING 
		PAYMENTSUM = SFLIGHT-PAYMENTSUM 
		SEATSOCC   = SFLIGHT-SEATSOCC 
		PRICE	= SFLIGHT-PRICE 
	 IMPORTING 
		LOSS	 = P_LOSS 
		REVENUE	= P_REVENUE 
	 EXCEPTIONS 
		OTHERS	 = 1. 
 ... 
ENDSELECT. 
... 
 
 
TABLES SFLIGHT. 
DATA: ITAB LIKE BCAXX OCCURS 10 WITH HEADER LINE, 
	P_YEAR LIKE ... .
CALL FUNCTION 'FILL_SEATTAB' 
	 EXPORTING
		YEAR	 = P_YEAR
	 TABLES 
		SEATTAB  = ITAB 
	 EXCEPTIONS 
		NO_ENTRY = 1 
		OTHERS   = 2.
CASE SY-SUBRC.
	 WHEN 1. ... 
	 WHEN 2. ...
ENDCASE. 
...