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

call a BAPI function for twice

former_member220801
Participant
0 Likes
995

I need to create a pair of article document by using 'BAPI_GOODSMVT_CREATE'. If the second article document has error, the first one should be rollback.

However, when I call the function for the second time, an error said that the function cannot be called until a work is committed for the previous function call. But once I called 'BAPI_TRANSACTION_COMMIT', the first document cannot be rollback even though I found errors when creating the second document.

I wonder if there are any ways to achieve this? Thanks!

(I know that I can create a single document with 2 items in it... but in my case, I need to to create 2 separate documents)

2 REPLIES 2
Read only

Former Member
0 Likes
569

Hi

I guess you can try this.

Call first 'BAPI_GOODSMVT_CREATE' in test run i.e. set the test flag.

If it gives success call second 'BAPI_GOODSMVT_CREATE' in test run.

If this also give success then call both without test flag set.

then u can commit both with 'BAPI_TRANSACTION_COMMIT'.

Regds,

Mithlesh

Read only

0 Likes
569

Hi!

This is not possible in a direct way: one goods receipt is a complete transaction, you can't call a 2nd transaction without doing a commit beforehand.

But the workaround Mithlesh proposed is quite good. Just a small performance improvement:

- Call the 2nd in test mode

- If test is OK, call 1st without test

- If 1st is OK, commit work

- If 1st was OK, book 2nd (+ commit work)

Regards,

Christian