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

Why we cannot commit inside BAPI and what if we call workflow inside BAPI?

Former Member
0 Likes
1,207

hi,

can anyone tell me why we cannot use Commit statement inside BAPI ?

Also what if in my BAPI ,i have triggered my workflow and through that can i commit??

Regards,

Mayank

4 REPLIES 4
Read only

romanweise
Active Contributor
0 Likes
893

Hi,

it is a part of the BAPI programming model that BAPIs use a certain transaction model. This transaction model says that one BAPI has to follow the so called ACID (atomar, consistent, isolated, durable) principle. To ensure that a BAPI is atomar you cannot put a commit work just anywhere in mid of a BAPI as this would violate the modell. Furthermore BAPIs shall allow external commit handling that means it has to be possible to include several BAPI calls in one LUW. For this there are BAPIs which are only for committing or rolling back a transaction. For more detailed information you can check as usual the SAP help [click me|http://help.sap.com/saphelp_nw04/helpdata/EN/a5/3ec8654ac011d1894e0000e829fbbd/frameset.htm]

If would suppose that when you throw a workflow event it is triggered once the LUW is closed. At least SAP should work that way. But I have to admit in newer ABAP OO developments SAP often just calls the Event raising function module with the option to not wait for the DB commit. Seems there are some problems with the newer LUW concepts / OO and the old workflow technology. This can lead in worst case to events raised for objects which were rolled back later but SAP seems to accept that so it is in my oppinion an acceptable solution.

Hope that helps a bit

Roman

Read only

0 Likes
893

Hi,

As per the data you have given ,than i dont think from my workflow i can commit as it will again call a new LUW which doesnt fulfills ACID rules..

or if i didnot explain properly,then i will try to explain again.

I have written a Z Bapi , and inside that i have to call my workflow through which i have to commit.

Is it possible to commit in workflow? if yes than how??

Thanks,

Mayank

Read only

Former Member
0 Likes
893

Hi,

If you are calling the BAPI inside your custom code, then you can comit the after the bapi is executed.

But if the BAPI is triggering the workflow or any ohter object, then you should not write the commit inside the BAPI as the Logical Unit of work will not be satisfied.

Only the commit should happen after the transaction is successfully completed else the automatic rollback should occur..

This is called as Logical unit of work(LUW)

Regards

Shiva

Read only

Former Member
0 Likes
893

Hi,

This thread will answer properly the question asked.

For more details on this topic you can visit to the link below:

http://help.sap.com/saphelp_nw04/helpdata/EN/a5/3ec8654ac011d1894e0000e829fbbd/frameset.htm

Edited by: mayank verdia on Jul 19, 2009 9:27 PM