‎2007 Aug 08 11:35 AM
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
‎2007 Aug 08 11:41 AM
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}.
‎2007 Aug 08 11:37 AM
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
‎2007 Aug 08 11:38 AM
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.
‎2007 Aug 08 11:39 AM
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
‎2007 Aug 08 11:39 AM
‎2007 Aug 08 11:40 AM
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.
‎2007 Aug 08 11:41 AM
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}.
‎2007 Aug 08 11:46 AM
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