Update task mode in function module


We can call a function module in Update task mode by using  "IN UPDATE TASK" statement. It allows you to call a function module but it will not be executed/called until an update task is initiated by the 'COMMIT WORK' statement in the report.

This means that the program logic after calling the FM will immediately continue with the next line of ABAP code and the function module will wait for the commit work statement and after that it will be executed/called.

Example:



CALL FUNCTION 'ZAU_FUNCTION' IN UPDATE TASK
 EXPORTING
    P_UNAME       = sy-uname.

Loop at it_mara to wa_mara.
"Program continues without executing the function.
endloop.

commit work. "Commits all work to database and also starts all FM's running in update task

Why its used ?
Suppose you need to call / perform some actions only after database updation and not before that.