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: 

BAPI Commit

Former Member
0 Kudos
2,278

I have a question on how BAPI_TRANSACTION_COMMIT functions.

LOOP.

CALL FUNCTION BAPI_...

ENDLOOP.

BAPI_TRANSACTION_COMMIT.

In this case will calling the Commit after the loop endloop commit all posted documents or will it commit only the last transaction?

I know that the commit inside the loop will commit the document but how does it function if we have it outside the loop?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1,124

Hi..

If you don;t put te COMMIT inside the loop, you might get 'locking issues'.

if you put the COMMIT outside the loop, most prob only one 'lucky' record might get committed

Cheers

~Arun

3 REPLIES 3

Former Member
0 Kudos
1,125

Hi..

If you don;t put te COMMIT inside the loop, you might get 'locking issues'.

if you put the COMMIT outside the loop, most prob only one 'lucky' record might get committed

Cheers

~Arun

Former Member
0 Kudos
1,124

This method executes a COMMIT WORK command. It is required for transactions developed externally to the R/3 system that change data in the R/3 system via BAPI calls. When you call BAPIs in your program that change data in the R/3 system,afterwards you must call this method to write changes to database.

This has an importing parameter WAIT, if WAIT is blank or SPACE, only a COMMIT work is executed, if it is filled with some value, the system executes a COMMIT WORK AND WAIT.

If the commit is not executed properly then exporting parameter RETURN will have a value indicating the user that it got error, this happens only when a WAIT (importing parameter) is set to some value. But WAIT is kept blank and the commit doesn't get executed properly then system crashes.

Hope this explains you better.Please reward points.

In your case, you should put it inside the LOOP ....ENDLOOP if the FM BAPI_.... handles the locking th*en there is no problem. But keeping outside will not COMMIT all the records, it will do only the last one.But remember to handle the locking.

Deepti..

Edited by: Deepti Kaza on Feb 5, 2008 11:00 PM

Former Member
0 Kudos
1,124

hi,

BAPI_TRANSACTION_COMMIT is used when you make changes to the SAP database by calling

a BAPI from outside SAP and want to commit the database. When you use a BAPI, you can not

directly use commit work, instead you are allowed to use only

BAPI_TRANSACTION_COMMIT.

BAPI_TRANSACTION_COMMIT is used with some of the BAPIs.

incase you call the bapi inside a loop, then the BAPI_TRANSACTION_COMMIT also has to be called inside the loop.

reward points if useful..