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
859

Hi All,

In a program .. why we are useing Commit Work..

what its purpose..

can any one explain clearly.

regards,

8 REPLIES 8
Read only

Former Member
0 Likes
809

Hi,

This statement will apply any outstanding database updates and wait until they have actually been put on the database before proceeding to the next statement.

An ordinary commit work will initiate the process to update the databases in a separate task and will press on in your abap.

COMMIT WORK: ( Asynchronous)

Your program does not wait for any acknowledgement. it just start executing the next statment after COMMIT WORK.

Regards

Nilesh

Read only

Former Member
0 Likes
809

Hi

Once you give commit in the program after DML or DDL operations on the database table then they will be effected to database table. If you dont give commit statement the changes will be effected to database table once you come out of the program.

Regards

Haritha.

Read only

0 Likes
809

Hi Haritha,

i am writing below code...pls.veryfy..

SELECT PERNR

STAT2

FROM PA0000

INTO TABLE IT_PA0000

WHERE PERNR IN S_PERNR AND

ENDDA GE S_DATE-LOW AND

BEGDA LE S_DATE-HIGH AND

STAT2 IN S_STAT2.

IF SY-SUBRC EQ 0.

COMMIT WORK.

SORT IT_PA0000 BY PERNR.

DELETE ADJACENT DUPLICATES FROM IT_PA0000.

ENDIF.

Here i used commit work ..what happend??

rgds,

Read only

0 Likes
809

Hi,

Here this statement is NOT required.

COMMIT WORK is mostly used when you do some DB operations such as inserting new entries in the DB table.

This is to be used after processing of BAPI.

Regards,

Atish

Read only

0 Likes
809

whenever u make changes in the database table we use commit statment.. so that the changes will be reflected in the table.

for example if u use insert, modify , update , delete syntax we have to use commit statement.

select statment wont modify the table it just fetches data from table so there is no need of this statement here.

Read only

Former Member
0 Likes
809

Hi,

Commit is used to save the records in the database...

See in SAP there will be Header data and Footer data..

Header will contain like data,Customer name,Address etc.,

Footer data will have if any materials is coming from the customer ..it will have more than one data,like one customer cansend more than one material...

Here when we insert the header data it will store in DB,after tht while u storing the footer data u cancel everything means the data saved in the header table also want to deleted....

So here COMMIT plays its role..when footer data is added and saved means finally commit will work...Otherwise the rollback will be called and every thing will be deleted

REWARD if useful

Read only

former_member198270
Active Contributor
0 Likes
809

Hi Vijay ,

The <b>Commit Work</b> 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 <b>Commit work</b> is called.

When u explicitly mention <b>Commit</b>, <b>Commit work</b> 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.

<i>Reward points if helpful.</i>

Regards,

Amber S

Read only

Former Member
0 Likes
809

Hi Vijay,

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,

Hemant