‎2006 Jan 26 4:50 AM
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)
‎2006 Jan 26 5:29 AM
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
‎2006 Jan 26 7:39 AM
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