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_TRANSACTION_ROLLBACK necessary?

Former Member
0 Kudos

To commit changes made by BAPIs like BAPI_PO_CREATE1 it is necessary to call BAPI_TRANSACTION_COMMIT.

Question is: Is it also necessary to call BAPI_TRANSACTION_ROLLBACK in case of an error?

e.g. BAPI_PO_CREATE1 does not succeed and returns an error message in RETURN table. Do I have to execute an rollback now?

If I test BAPI_PO_CREATE1 and it succeeds a po number is returned. Without calling COMMIT or ROLLBACK now will this number garble the system or is it save to forget it simply?

Thanks!

Florian

6 REPLIES 6

former_member223537
Active Contributor
0 Kudos

Hi,

In case of a WARNING message, the ROLLBACK wont happen automatically whereas in case of an ERROR message, the ROLLBACK would happen.

But to be on safer side, it is always good to call BAPI_TRANSACTION_ROLLBACK irrespective of the message type ( Warning or Error).

Same is the case with COMMIT. If you dont give an explicit commit work, the data would be COMMITED once the transaction/process is completed without any error/warning messages.

Best regards,

Prashant

Former Member
0 Kudos

Its a fail safe practice to do it. There might be a number of global variables, LUWs which might be sitting in the buffer. As you will not be aware of what SAP std code is inside BAPI_PO_CREATE1, it is better to call FM BAPI_TRANSACTION_ROLLBACK as a fail safe practice.

Ideally this is for the case where you call

BAPI 1

BAPI 2

BAPI 3 in a chain

and execute the rollback work in case any of them fails in the chain to make sure that a system rollback occurs to the original state.

Hope this answers the query

Cheers

Kareem

former_member181962
Active Contributor
0 Kudos

Hi Florina,

There is a parameter TESTRUN in the interface of this bapi. BAPI_PO_CREATE1.

If you set that to X, then you need to do a commit explicitly afterwards(If successful).

If you don't use the TESTRUN = 'X', it would have already commited the changes by then .

Regards,

Ravi

0 Kudos

To my knowledge this is not the case at least with release 4.7. When my call to the BAPI succeeds a number is returned but the po can only be seen (e.g. by me23) after a call to transaction commit.

I think TESTRUN will prevent a number to be created if the BAPI is successfull.

Florian

0 Kudos

Hi again,

1. Since it is a BAPI, it can be saved only via COMMIT afterwards.

2. So If Test run = 'X',

then commit work will not have any effect bcos

Test run means that no data will be saved.

3. However, it seems that the number range (new number)

will anyhow get created in the system.

(Whether we give test run or not, the new number range gets created and saved)

regards,

amit m.

Former Member
0 Kudos

Hi florian,

1. BAPI_PO_CREATE1 does not succeed

In that case, nothing is saved in database,

and so,

neither commit nor rollback is required.

regards,

amit m.