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 After Insert or Update

Former Member
5,029

Hi,

Is it mandatory to write Commit Work after Insert or Update into DataBase Table.?

Without writing also it is working fine.

Can you please let me know..what is the exact significance of this.....

Please explain in Brief...

I have seen so many links...But dint get exactly ....what the significance is...

Thanks,

Sandip

1 ACCEPTED SOLUTION
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
2,839

Commit work.

Will do an explicit db commit.

Both insert and update also perfom an implicit db commit.

The significance of explicit commitw ork comes in to picture when your DB updates faila nd you want to rollback .

So best way is to check sy-subrc after insert/update and if it fails then rollback work else do a commit.

4 REPLIES 4
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
2,840

Commit work.

Will do an explicit db commit.

Both insert and update also perfom an implicit db commit.

The significance of explicit commitw ork comes in to picture when your DB updates faila nd you want to rollback .

So best way is to check sy-subrc after insert/update and if it fails then rollback work else do a commit.

Read only

Former Member
0 Likes
2,839

Hi Sandeep,

The COMMIT WORK statement always sets sy-subrc to 0 if the AND WAIT addition is not specified. It triggers a database exception in programs that are called using CALL DIALOG. This executes all high-priority (VB1) update function modules in the order of their registration and in a common database LUW.It triggers a database commit that also terminates the current database LUW and closes all database cursors.

If u r doing any operation in DB, to save that COMMIT used.

Thanks,

Sneha.

Read only

Former Member
0 Likes
2,839

Hi

U should read the information (or SAP Help) about LUW (Logical Unit of Work).

Here u can find out all answeres you need.

Max

Read only

Former Member
2,839

All the statements will be added to logical unit of work and this logical unit of work is submitted to database after periodic interval, if you want you can write COMMIT to have it done explicitly.

This is done when you want database to reflect new values instantonously.