‎2007 Jan 18 7:20 AM
Hi,
Can anyone tell me what happens when we explicitly write " COMMIT " or " COMMIT WORK" statement in module pool.
Thanks
‎2007 Jan 18 7:23 AM
hi Amit..
WELCOME TO SDN
COMMIT
Variants:
1. COMMIT WORK.
2. COMMIT CONNECTION con.
Effect
Executes a database commit and thus closes a Logical Unit of Work ( LUW) (see also Transaction Processing). This means that:
All database updates are made irrevocable and cannot be reversed with ROLLBACK WORK
All database locks are released.
COMMIT WORK belongs to the Open-SQL command set.
Variant 1
COMMIT WORK.
Addition:
... AND WAIT
Effect
COMMIT WORK also
Calls the subroutines specified by PERFORM ... ON COMMIT
Executes asynchronously any update requests (see CALL FUNCTION ... IN UPDATE TASK) specified in these subroutines or started just before
Processes the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK
Resets the time slice counter to 0.
Ensures that the locks of the SAP locking concept are handled in accordance with its SCOPE Parameter.
Executes a database commit on all database connections
Closes all open database cursors (OPEN CURSOR) on all database connections
Releases all database locks on all database connections
After the COMMIT WORK has been executed, the event RAISE_TRANSACTION_FINISHED of the class CL_SYSTEM_TRANSACTION_STATE with parameter value CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK is triggered. However, this does not apply to the COMMIT WORK at the end of the update.
The Return Code SY-SUBRC is set to 0.
Notes
All subroutines called with PERFORM ... ON COMMIT are processed in the LUW concluded by the COMMIT WORK command. All V1 update requests specified in CALL FUNCTION ... IN UPDATE TASK are also executed in one LUW. When all V1 update requests have been successfully concluded, the V2 update requests (update with start delayed ) are processed, each in one LUW. Parallel to this, the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK are each executed in one LUW per destination.
COMMIT WORK commands processed within CALL DIALOG processing do all of the following:
- A database commit on all database connections (see above),
- Close all open database cursors on all database connections
- Reset the time slice counter
- Call the function modules registered in CALL DIALOG processing using CALL FUNCTION IN BACKGROUND TASK
However, subroutines and function modules called with PERFORM ... ON COMMIT or CALL FUNCTION ... IN UPDATE TASK in CALL DIALOG processing are not executed in the calling transaction until a COMMIT WORK occurs.
Since COMMIT WORK closes all open database cursors, any attempt to continue a SELECT loop after a COMMIT WORKresults in a runtime error. For the same reason, a FETCH after a COMMIT WORK on the now closed cursors also produces a runtime error. You must therefore ensure that any open cursors are no longer used after the COMMIT WORK.
COMMIT WORK may not be used during the update (CALL FUNCTION ... IN UPDATE TASK) or during the execution of FORMs that were registered using PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK.
With batch input and CALL TRANSACTION ... USING, COMMIT WORK successfully concludes the processing.
Addition
... AND WAIT
Effect
The addition ... AND WAIT makes the program wait for the type V1 update (update with immediate start) to be executed.
The Return Code is set as follows:
SY-SUBRC = 0:
The update was performed successfully.
SY-SUBRC <> 0:
The update was not performed successfully.
Variant 2
COMMIT CONNECTION con.
Effect
The COMMIT command is not executed on the standard database, but only on the secondary database connection specified with con. con is the name of the database connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text) - the source_text field contains the name of the database connection as ABAP Source Code.
On the specified secondary database connection, the database commit:
Closes all open database cursors (OPEN CURSOR)
Releases all database locks
Note
Because all open database cursors are closed with the COMMIT, the attempt to continue a SELECT loop after a COMMIT causes a runtime error. For the same reason, a FETCH after the COMMIT to the now closed cursor causes runtime error. You must ensure that open cursors are no longer used after the COMMIT. The only exception are cursors that were opened using the WITH HOLD addition.
‎2007 Jan 18 7:23 AM
hi Amit..
WELCOME TO SDN
COMMIT
Variants:
1. COMMIT WORK.
2. COMMIT CONNECTION con.
Effect
Executes a database commit and thus closes a Logical Unit of Work ( LUW) (see also Transaction Processing). This means that:
All database updates are made irrevocable and cannot be reversed with ROLLBACK WORK
All database locks are released.
COMMIT WORK belongs to the Open-SQL command set.
Variant 1
COMMIT WORK.
Addition:
... AND WAIT
Effect
COMMIT WORK also
Calls the subroutines specified by PERFORM ... ON COMMIT
Executes asynchronously any update requests (see CALL FUNCTION ... IN UPDATE TASK) specified in these subroutines or started just before
Processes the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK
Resets the time slice counter to 0.
Ensures that the locks of the SAP locking concept are handled in accordance with its SCOPE Parameter.
Executes a database commit on all database connections
Closes all open database cursors (OPEN CURSOR) on all database connections
Releases all database locks on all database connections
After the COMMIT WORK has been executed, the event RAISE_TRANSACTION_FINISHED of the class CL_SYSTEM_TRANSACTION_STATE with parameter value CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK is triggered. However, this does not apply to the COMMIT WORK at the end of the update.
The Return Code SY-SUBRC is set to 0.
Notes
All subroutines called with PERFORM ... ON COMMIT are processed in the LUW concluded by the COMMIT WORK command. All V1 update requests specified in CALL FUNCTION ... IN UPDATE TASK are also executed in one LUW. When all V1 update requests have been successfully concluded, the V2 update requests (update with start delayed ) are processed, each in one LUW. Parallel to this, the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK are each executed in one LUW per destination.
COMMIT WORK commands processed within CALL DIALOG processing do all of the following:
- A database commit on all database connections (see above),
- Close all open database cursors on all database connections
- Reset the time slice counter
- Call the function modules registered in CALL DIALOG processing using CALL FUNCTION IN BACKGROUND TASK
However, subroutines and function modules called with PERFORM ... ON COMMIT or CALL FUNCTION ... IN UPDATE TASK in CALL DIALOG processing are not executed in the calling transaction until a COMMIT WORK occurs.
Since COMMIT WORK closes all open database cursors, any attempt to continue a SELECT loop after a COMMIT WORKresults in a runtime error. For the same reason, a FETCH after a COMMIT WORK on the now closed cursors also produces a runtime error. You must therefore ensure that any open cursors are no longer used after the COMMIT WORK.
COMMIT WORK may not be used during the update (CALL FUNCTION ... IN UPDATE TASK) or during the execution of FORMs that were registered using PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK.
With batch input and CALL TRANSACTION ... USING, COMMIT WORK successfully concludes the processing.
Addition
... AND WAIT
Effect
The addition ... AND WAIT makes the program wait for the type V1 update (update with immediate start) to be executed.
The Return Code is set as follows:
SY-SUBRC = 0:
The update was performed successfully.
SY-SUBRC <> 0:
The update was not performed successfully.
Variant 2
COMMIT CONNECTION con.
Effect
The COMMIT command is not executed on the standard database, but only on the secondary database connection specified with con. con is the name of the database connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text) - the source_text field contains the name of the database connection as ABAP Source Code.
On the specified secondary database connection, the database commit:
Closes all open database cursors (OPEN CURSOR)
Releases all database locks
Note
Because all open database cursors are closed with the COMMIT, the attempt to continue a SELECT loop after a COMMIT causes a runtime error. For the same reason, a FETCH after the COMMIT to the now closed cursor causes runtime error. You must ensure that open cursors are no longer used after the COMMIT. The only exception are cursors that were opened using the WITH HOLD addition.
‎2007 Jan 18 7:23 AM
When a COMMIT WORK statement is encountered, all the bundled updates (bundled using perform on commit or call function in update task) will be executed. That is when the actual database update happens. All the updates happen one after the other in the sequence in which they were called earlier.
Manoj
‎2007 Jan 18 7:24 AM
All changes from the last save will be saved to the database. The current LUW (Logical Unit of Work) gets saved. All DB modifications in the current LUW gets saved.
‎2007 Jan 18 7:27 AM
Hi
please go thru this url
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/commit.htm
http://www.sapdb.org/7.4/htmhelp/5e/eba66a440a11d3a98200a0c9449261/content.htm
Thanks
Shiva