Application Development 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: 

Commit work

Former Member
0 Kudos

hi

What is the purpose of Commit work command?

When do we use it and how does it work?

Please clearify with an example.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

commit work is mainly used for database operations .

commit work means if all the stetments above that works fine then it will execute if one fails it won't execute

you can see discription here

reward if usefull

The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the currenta SAP LUW in the process. In this case, COMMIT WORK performs the following actions:

It executes all subroutines registered using PERFORM ON COMMIT.

It triggers an internal event in Object Services that ensures the registration of changes in persistent objects as the last update function module, as well as the subsequent initialization of persistent object attributes.

It initiates the processing of all registered update function modules in the update work process.

This executes all high-priority update function modules registered using CALL FUNCTION ... IN UPDATE TASK in the order of their registration and in a common database LUW. If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating). If you specify the addition AND WAIT, however, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).

If all high-priority update function modules are completed successfully, the statement executes the low-priority update function modules together in a common database LUW.

In parallel, it also executes the individual function modules registered using CALL FUNCTION ... IN BACKGROUND TASK DESTINATION in a separate database LUW for each destination.

It handles all SAP locks set in the current program according to the value of the formal parameter _SCOPE of the corresponding lock function modules.

It triggers a database commit that also terminates the current database LUW.

The completion of statement COMMIT WORK triggers the event TRANSACTION_FINISHED of the system class CL_SYSTEM_TRANSACTION_STATE, where the parameter KIND has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK.

If the statement COMMIT WORK is executed by calling special programs, be aware of the following:

In a program executed using batch input, or if you have called the program using the USING addition of the statement CALL TRANSACTION, COMMIT WORK terminates the batch input processing when using the corresponding settings.

In a program called using CALL DIALOG, COMMIT WORK initiates the processing of subroutines or updated function modules registered using PERFORM ... ON COMMIT and CALL FUNCTION ... IN UPDATE TASK. Therefore, it does not complete the current SAP LUW. The SAP LUW cannot be completed until you execute the COMMIT WORK statement in the calling program.

You cannot execute the COMMIT WORK statement during the updating procedure or during the execution of subroutines registered using PERFORM ... ON {COMMIT|ROLLBACK}.

2 REPLIES 2

Former Member
0 Kudos

Hi

commit work is mainly used for database operations .

commit work means if all the stetments above that works fine then it will execute if one fails it won't execute

you can see discription here

reward if usefull

The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the currenta SAP LUW in the process. In this case, COMMIT WORK performs the following actions:

It executes all subroutines registered using PERFORM ON COMMIT.

It triggers an internal event in Object Services that ensures the registration of changes in persistent objects as the last update function module, as well as the subsequent initialization of persistent object attributes.

It initiates the processing of all registered update function modules in the update work process.

This executes all high-priority update function modules registered using CALL FUNCTION ... IN UPDATE TASK in the order of their registration and in a common database LUW. If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating). If you specify the addition AND WAIT, however, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).

If all high-priority update function modules are completed successfully, the statement executes the low-priority update function modules together in a common database LUW.

In parallel, it also executes the individual function modules registered using CALL FUNCTION ... IN BACKGROUND TASK DESTINATION in a separate database LUW for each destination.

It handles all SAP locks set in the current program according to the value of the formal parameter _SCOPE of the corresponding lock function modules.

It triggers a database commit that also terminates the current database LUW.

The completion of statement COMMIT WORK triggers the event TRANSACTION_FINISHED of the system class CL_SYSTEM_TRANSACTION_STATE, where the parameter KIND has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK.

If the statement COMMIT WORK is executed by calling special programs, be aware of the following:

In a program executed using batch input, or if you have called the program using the USING addition of the statement CALL TRANSACTION, COMMIT WORK terminates the batch input processing when using the corresponding settings.

In a program called using CALL DIALOG, COMMIT WORK initiates the processing of subroutines or updated function modules registered using PERFORM ... ON COMMIT and CALL FUNCTION ... IN UPDATE TASK. Therefore, it does not complete the current SAP LUW. The SAP LUW cannot be completed until you execute the COMMIT WORK statement in the calling program.

You cannot execute the COMMIT WORK statement during the updating procedure or during the execution of subroutines registered using PERFORM ... ON {COMMIT|ROLLBACK}.

Former Member
0 Kudos

Hi Rahul,

what is the relation between you and naresh casually asking

when ever u post naresh is getting 10 points even if some other persons posting to ur questions u r not giving single point

any way thanks for closing threads,

Best Regds,

Kiran.M