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

Commit work

Former Member
0 Likes
1,077

Hi,

What is the purpose of Commit work command?

When do we use it and how does it work?

Please clearify with an example.

Thanks in advance.

Regards,

Neeraja

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
887

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}.

7 REPLIES 7
Read only

Former Member
0 Likes
887

commit work statement is used for db commit.

reverse is rollback

example

for bapi u can commit using BAPI_TRANSACTION_COMMIT using wait parameter.

Sameer

Read only

Former Member
0 Likes
887

Hi,

The Commit Work executes a database commit and thus closes a Logical Unit of Work ( LUW).

The updates and insert in a DB are rolled back in case the program abruptly terminates.

In case of successful completion, the Commit work is called.

When u explicitly mention Commit, Commit work is called then n then n u see the entry in the DB.

The reason u dont see entry in the DB sometimes is probably due to abrupt end of program as a result of which the transactions are rolled back.

To apply the changes made to the runtime objects of persistent classes to the actual persistent objects in the database, execute the COMMIT WORK statement

Commit work is used when you code directly in ABAP and make changes in the database and want to commit the database.

Commit work can be used when you trigger a workflow event by using Function module (swe_event_create) in your program.

Regards,

Priyanka.

Read only

Former Member
0 Likes
887

Hi,

When ever the SAP Table is updated or inserted with values we call commit work to save the data

Update <table> set field = '1234'

where -


commit work

Regards

Arun

Read only

Former Member
Read only

Former Member
0 Likes
887

HI,

To apply the changes made to the runtime objects of persistent classes(tables) to the actual persistent objects in the database we will write the COMMIT WORK statement.

see this link for more hep

http://help.sap.com/saphelp_nw2004s/helpdata/en/d2/7849b8bec911d4b2e80050dadfb92b/content.htm

rgds,

bharat.

Read only

Former Member
0 Likes
888

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}.

Read only

Former Member
0 Likes
887

Hi,

Commit work statement is used to 'explicitly' end the SAP LUW.

This is a must when you are using various update techniques (e.g. update function modules)...

Regards,

Abhijit