Function module IN UPDATE TASK statement - Execute abap code in seperate unit of work

The IN UPDATE TASK statement allows you to call a function module but it will not be executed until an update task is initiated by the 'COMMIT WORK' statement. This means that the program logic after calling the FM will immediately continue with the next line of ABAP code and the FM will sit and wait for the commit work. This also allows you to execute several sections of code asynchronously by calling the ABAP function module with the IN UPDATE TASK statement then performing the commit work command. See example below!

If you are thinking of using this functionality please consider if it is actually an update task you want rather than a background task. The 'IN BACKGROUND TASK' works in exactly the same but performs the final processing in background rather than using one of the update processes available on your SAP system.

Your SAP system will have X number of update process and X number of background processes available. If the processing takes a long time and it is a program that is used by many people you could quite easily use up all the available update processes causing any other important database updates to be queued up behind these. Update processes really should be very quick, i.e. if you update your personnel details this should be committed to the database within an update task and should take seconds or even milliseconds. If you are processing a lot of data which takes minutes you might need to consider if it really should be an update task and if a background task wouldn't be more appropriate.

Example ABAP code to execute FM in update task within separate unit of work

CALL FUNCTION 'Z_FMODULE' IN UPDATE TASK
 EXPORTING
    P_UNAME       = sy-uname.
commit work. "Commits all work to database and also starts all FM's running in update task
"loop at it_ekko. "program continues with next line of ABAP without waiting for update and FM to finish
"...
"endloop.

Also see:
STARTING NEW TASK
IN UPDATE TASK
IN BACKGROUND TASK


Related Articles

ABAP COLLECT statement syntax to add up all numeric internal table values within SAP
ABAP DELETE statement keyword to delete data from SAP internal and database tables
ABAP DESCRIBE statement keyword to get information about tables and fields
PERFORM TABLES command passing internal table as parameter
ABAP read command to read line of internal table in SAP
ABAP UPDATE command to modify database field values
AUTHORITY-CHECK abap Statement / command
ABAP delete command in SAP
ABAP MODIFY statement to update SAP data within database and internal tables
ABAP WRITE statement command with in SAP to display data report to users
SAP ABAP Statement syntax including basic implementation code
Concatenate ABAP statement syntax for concatenating data objects, sting values or rows of an SAP internal table
ABAP EXPORT data TO MEMORY ID and import it back again
IF, CHECK & WHEN ABAP commends example source code and information
Call Function module IN BACKGROUND TASK - Execute abap code in seperate background process
ABAP STRLEN command to get the value length of a SAP field
SAP ABAP SELECT command and its different uses
SELECT..ENDSELECT command
ABAP FOR ALL ENTRIES SELECT statement addition in SAP data retrieval
ABAP SELECT inner join statement to select from two tables at the same time
SELECT directly into an internal table
SELECT directly into an internal table when field order is different
Function module STARTING NEW TASK statement - Execute abap code in seperate work process