Table of Contents
Function modules are procedures that have a set of re-usable statements with importing, exporting parameters, etc. They are created in ABAP workbench using the Function Module Builder. They play an important role in updating and in the interaction between different SAP systems, between SAP systems and remote systems through remote calls.
There are 3 Processing types of function module:
- Regular Function Module
- Remote-Enabled Function Module
- Update Module
Regular Function Module
Regular Function Module and Update Function module consists of a block of statements that are made available globally all over the SAP landscape.
The Update function module is a function module for which the processing type property of the function builder is set to Update Module. This function module is not executed immediately but is scheduled for execution in a special work process called update work process. For this purpose, the name of the update function module along with the actual parameter is registered in the database table VBLOG as a log record.
Syntax to register the function module to the log table:
CALL FUNCTION <function_name> IN UPDATE TASK[EXPORTING p1 = a1 … fn = an] [TABLES f1 = a1 … fn = an
The actual execution of the program is triggered by the COMMIT WORK statement. The values of the actual parameters are received by the formal parameter of the function module from the VBLOG table. After registration of the function module, if the COMMIT WORK is not triggered then the function module is not executed and the entries are deleted from the log table when the program ends.
The regular function module does not need to be registered to be called. This is executed immediately whenever a call to this function module is made. Sy-subrc can be checked for success and failure.
Syntax to call a Regular function module:
CALL FUNTION <function_name>[EXPORTING p1 = a1 … fn = an] [IMPORTING f1 = a1 … fn = an] [CHANGING f1 = a1 … fn = an] [TABLES f1 = a1 … fn = an] [EXCEPTIONS e1 = r1 … en = rn [ERROR_MESSAGE = rE] [OTHERS = ro]].
Now, let’s have a look at their difference.
Difference between Update function module and Regular function module
|Update Function Module||Regular Function Module|
|It needs to be registered first in the log table||There is no need to register|
|It is executed when COMMIT WORK statement is triggered.||It is executed immediately when a call is made to this function.|
|Sy-subrc is undefined after execution||Sy-subrc can be checked after the execution|