You can call a function module from any ABAP program by using the following ABAP statement:
CALL FUNCTION <function module name> [EXPORTING f1 = a1.... fn = an] [IMPORTING f1 = a1.... fn = an] [CHANGING f1 = a1.... fn = an] [TABLES t1 = itab1.... tn = itabn] [EXCEPTIONS e1 = r1.... en = rn] [ERROR_MESSAGE = rE] [OTHERS = ro]].
CALL FUNCTION Statement
You enter the name of the function module <function module> as a literal. In the EXPORTING , IMPORTING , CHANGING , and TABLES options, you pass parameters by explicitly assigning the actual parameters to the formal parameters. You assign parameters following the scheme: <formal parameter> = <actual parameter> .If you assign multiple parameters within an option, insert spaces between them or start a new line.
If the exception e i is triggered, the system terminates the function module and does not pass any values back to the program.The calling program accepts the exception e i by assigning the value r i to the system field SY-SUBRC. This value functions as a return code (r i must be a numeric literal). In the calling program, you can evaluate the system field.
You can change the error handling in the function module by specifying an ERROR_MESSAGE in the EXCEPTIONS list. Messages should only be called in exception handling (using the statements MESSAGE.....RAISING or RAISE in the function module). For more information, see Overview of Coding for Function Modules .
If you enter OTHERS in the EXCEPTION list, you can allow for all exceptions, even though they are not listed. That functions as a default exception.
You can use the same number r i for different exceptions, as long as the system does not require further specification of the exceptions.
try. call function 'FB_EXCEPTION_TEST' exporting p1 = p2 = * IMPORTING * P3 = * P4 = . catch cx_sy_zerodivide. endtry.
There are other parameters you can use with the CALL FUNCTION statement, if the function is to be executed in an update task or on a remote host.
For more information about how to call function modules from your programs, see the Function Modules section of the ABAP User Guide .