Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calling Function Module in Update Task

Former Member
49,353

Hello Experts,

Can anyone let me know about

Calling Function Module in Update Task.

Why do we use this " In Update Task " ??

How do we Use ??

What is the Use... ??

Kindly let me know....

Thanks and Regards

Pramod

1 ACCEPTED SOLUTION
Read only

Former Member
22,688

hi,

Why do we use this " In Update Task " ??

The main update technique for bundling database changes in a single database LUW is to use CALL FUNCTION... IN UPDATE TASK.

How do we Use ??

A typical R/3 installation contains dialog work processes and at least one update work process. The update work processes are responsible for updating the database. When an ABAP program reaches a COMMIT WORK statement, any function modules from CALL FUNCTION... IN UPDATE TASK statements are released for processing in an update work process. The dialog process does not wait for the update to finish. This kind of update is called asynchronous update.

What is the Use... ??

Asynchronous update is useful when response time from the transaction is critical, and the database updates themselves are so complex that they justify the extra system load

Real time scenario.

Suppose a user wants to change an entry in a database table, or add a new one. He or she enters the necessary data, and then starts the update process by choosing Save. This starts the following procedure in the ABAP program:

Firstly, the program locks the database entry against other users, using the enqueue work process (or the message server in the case of a distributed system). This generates an entry in the lock table. The user is informed whether the update was successful, or whether the lock could not be set because of other users.

If the lock is set, the program reads the entry that is to be changed and modifies it. If the user has created a new entry, the program checks whether a record with the same key values already exists.

In the current dialog work process, the program calls a function module using CALL FUNCTION... IN UPDATE TASK, and this writes the change details as an entry in table VBLOG.

When the program is finished (maybe after further dialog steps), a COMMIT WORK statement starts the final part of the SAP LUW. The work process that is processing the current dialog step starts an update work process.

Based on the information passed to it from the dialog work process, the update work process reads the log entries belonging to the SAP LUW from table VBLOG.

The update work process passes this data to the database for updating, and analyzes the return message from the database. If the update was successful, the update work process triggers a database commit after the last database change and deletes the log entries from table VBLOG.

If an error occurred, the update work process triggers a database rollback, leaves the log entries in table VBLOG, flags them as containing errors, and sends a SAPoffice message to the user, who should then inform the system administrator.

The corresponding entries in the lock table are reset by the update work process.

Hope this is helpful, Do reward.

4 REPLIES 4
Read only

i048168
Product and Topic Expert
Product and Topic Expert
0 Likes
22,688

hI,

The system logs your request and executes the function module when the next COMMIT WORK statement is reached. The parameter values used to execute the function module are those current at the time of the call.

a = 1.

CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A...

a = 2.

CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A...

a = 3.

COMMIT WORK.

Here, the function module UPD_FM is performed twice in the update task: the first time, with value 1 in PAR, the second time with value 2 in PAR.

Regards

Vadi

Read only

Former Member
0 Likes
22,688

In function module what is the use optional?

Read only

Former Member
0 Likes
22,688

Hi

Check the SAP Help :

http://help.sap.com/saphelp_nw04s/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/frameset.htm

SAP uses LUW (logical unit of work) concept, with this it basically does a sequence of steps and if all of them were successful it commits all the data to the database. During this process it keeps all the data in temporary memory. So lets say in your process you have 4 steps that complete the process, so you want to commit only when all the 4 steps are successful, in this case you will use CALL FM in UPDATE TASK for all the 4 of them, once the 4th FM is successful you use the statement COMMIT WORK to commit all the changes to the database.

Sy-subrc will have 4 ,then comitt work will not happen.

Thanks

Read only

Former Member
22,689

hi,

Why do we use this " In Update Task " ??

The main update technique for bundling database changes in a single database LUW is to use CALL FUNCTION... IN UPDATE TASK.

How do we Use ??

A typical R/3 installation contains dialog work processes and at least one update work process. The update work processes are responsible for updating the database. When an ABAP program reaches a COMMIT WORK statement, any function modules from CALL FUNCTION... IN UPDATE TASK statements are released for processing in an update work process. The dialog process does not wait for the update to finish. This kind of update is called asynchronous update.

What is the Use... ??

Asynchronous update is useful when response time from the transaction is critical, and the database updates themselves are so complex that they justify the extra system load

Real time scenario.

Suppose a user wants to change an entry in a database table, or add a new one. He or she enters the necessary data, and then starts the update process by choosing Save. This starts the following procedure in the ABAP program:

Firstly, the program locks the database entry against other users, using the enqueue work process (or the message server in the case of a distributed system). This generates an entry in the lock table. The user is informed whether the update was successful, or whether the lock could not be set because of other users.

If the lock is set, the program reads the entry that is to be changed and modifies it. If the user has created a new entry, the program checks whether a record with the same key values already exists.

In the current dialog work process, the program calls a function module using CALL FUNCTION... IN UPDATE TASK, and this writes the change details as an entry in table VBLOG.

When the program is finished (maybe after further dialog steps), a COMMIT WORK statement starts the final part of the SAP LUW. The work process that is processing the current dialog step starts an update work process.

Based on the information passed to it from the dialog work process, the update work process reads the log entries belonging to the SAP LUW from table VBLOG.

The update work process passes this data to the database for updating, and analyzes the return message from the database. If the update was successful, the update work process triggers a database commit after the last database change and deletes the log entries from table VBLOG.

If an error occurred, the update work process triggers a database rollback, leaves the log entries in table VBLOG, flags them as containing errors, and sends a SAPoffice message to the user, who should then inform the system administrator.

The corresponding entries in the lock table are reset by the update work process.

Hope this is helpful, Do reward.