UPDATE FUNCTION MODULE
EXCERPT FROM THE SAP DOCUMENTATION: Function module for which the property update module
is selected in Function Builder. It is the basis of the update function. An update function module
generally performs modifying database accesses and the statement CALL FUNCTION ... IN UPDATE
TASK can be used to register it for execution later with the statement COMMIT WORK. When an
update function module is created it is assigned either a high or low priority level.
SCENARIO:
Let’s understand this with a scenario on how UPDATE FUNCTION MODULE would work.
For example, you have a transaction/program which saves the data into the table using an UPDATE
FUNCTION MODULE. So, upon clicking on the SAVE button in your transaction if the UPDATE
FUNCTION MODULE is executed but for some reason there is an error reported in the further part of
the logic then what would happen? Will the data still be written into the Database?
This is exactly where we see the magic of the UPDATE function module. Since the
transaction/program ends up in ERROR (even after UPDATE FUNCTION MODULE is called) the update
to the DB is NOT DONE as the LUW is not complete and the explicit COMMIT WORK is not
encountered. Function modules called in update task wait for a COMMIT WORK to be executed
explicitly in the calling program.
SYNTAX:
Figure 1. Syntax to call an update function module
Figure 2. Here, F1 and F3 are executed in the update task because the COMMIT WORK for the main program triggers their
execution. However, since transaction ZABC contains no COMMIT WORK statement, the function F2 is never executed by the
update task.