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: 

What is the difference in the behavior of DB_COMMIT and COMMIT WORK ?

issabella_martin1995
Participant
6,225

Hello Gurus,

I want to know what is the difference between FM DB_COMMIT and the ABAP statement COMMIT WORK. The function module DB_COMMIT will commit all the database changes (but COMMIT WORK will also do the same thing ) , then what is the significance of writing a DB_COMMIT . I read that DB_COMMIT will end the DB LUW and COMMIT WORK will end the SAP LUW but is there any practical example where we can demonstrate the difference between two?

1 ACCEPTED SOLUTION

former_member1716
Active Contributor
1,943

Hello subhant banerjee,

Both Commits you have mentioned above is just type Database Commits, let me explain further for better understanding!

What is a Database Commit?

These are commands/Controls that system posses to close all the opened cursors that are applied on the table.

In other words during program execution which directly/indirectly deals with tables, system will be locking the table up front until its operation is complete on the associated tables. These commit statements helps in releasing the table for other work processes i any.

These are two Types:

1) Implicit Commits

2) Explicit Commits


Implicit Commits:

These are the ones that will create its own work process to start and LUW, which means it will not interfere in other work process and waits until gets completed and once there are free Work process it will begin to start its LUW with the available work process. As the Name indicates, the call is implicit and in real time they get triggered at below Instances:

--> After completion of user interaction in any transaction.

--> After completion of FM call both Synchronous/Asynchronous Call.

--> When an external framework is used.

I short this Implicit Commits will work upon all open database connections

Explicit Commits

Well these are the commits we are most used to. As the name indicates the Commit statements that are explicitly coded in the program are called as Explicit Commit.

Even Calling the FM DB_COMMIT explicitly in the program is also Explicit Commit. We would have used it many of our developed objects.

As you have mentioned this Commit closes the open LUW that is running.

To Summarize:

--> An Implicit Commit (DB Commit) Closes only the Database Connections but an Explicit Commit in addition to DB connections it also closes the LUW which is Running.

--> An implicit Commit (DB Commit) waits for the Work process to get released to initiate its own LUWs for closing DB Connections but an Explicit Commit Will close the DB connections and the respective LUW in the same cycle and finish the necessary actions for the LUW.

--> This is the exact reason we explicitly call the COMMIT WORK statement because we wanted to progress further quickly with next steps of operations and we can't really afford to wait for system To close the DB connections on its ow time Frame.

Hope you got a better idea now!

Regards!

2 REPLIES 2

former_member1716
Active Contributor
1,944

Hello subhant banerjee,

Both Commits you have mentioned above is just type Database Commits, let me explain further for better understanding!

What is a Database Commit?

These are commands/Controls that system posses to close all the opened cursors that are applied on the table.

In other words during program execution which directly/indirectly deals with tables, system will be locking the table up front until its operation is complete on the associated tables. These commit statements helps in releasing the table for other work processes i any.

These are two Types:

1) Implicit Commits

2) Explicit Commits


Implicit Commits:

These are the ones that will create its own work process to start and LUW, which means it will not interfere in other work process and waits until gets completed and once there are free Work process it will begin to start its LUW with the available work process. As the Name indicates, the call is implicit and in real time they get triggered at below Instances:

--> After completion of user interaction in any transaction.

--> After completion of FM call both Synchronous/Asynchronous Call.

--> When an external framework is used.

I short this Implicit Commits will work upon all open database connections

Explicit Commits

Well these are the commits we are most used to. As the name indicates the Commit statements that are explicitly coded in the program are called as Explicit Commit.

Even Calling the FM DB_COMMIT explicitly in the program is also Explicit Commit. We would have used it many of our developed objects.

As you have mentioned this Commit closes the open LUW that is running.

To Summarize:

--> An Implicit Commit (DB Commit) Closes only the Database Connections but an Explicit Commit in addition to DB connections it also closes the LUW which is Running.

--> An implicit Commit (DB Commit) waits for the Work process to get released to initiate its own LUWs for closing DB Connections but an Explicit Commit Will close the DB connections and the respective LUW in the same cycle and finish the necessary actions for the LUW.

--> This is the exact reason we explicitly call the COMMIT WORK statement because we wanted to progress further quickly with next steps of operations and we can't really afford to wait for system To close the DB connections on its ow time Frame.

Hope you got a better idea now!

Regards!

issabella_martin1995
Participant
1,943

Thanks Satish for your answer. Really helpful.