Skip to Content
author's profile photo Former Member
Former Member

rollback multiple transaction

Hello Experts:

Got a quick question needs fast answer..

I am doing a sales order create and then turn into invoice. two function handle it.

BAPI_SALESORDER_CREATEFROMDATA for sales order and BAPI_BILLINGDOC_CREATEMULTIPLE to turn it into invoice. Sales order fail, that's fine. But if invoice failed. I want the sales order to roll back as well. Is there a start transaction ... then end with roll back or commit kind of thing in ABAP? Appreciate any hint at all.! !!!!

Sincerely Yours

Bo Peng

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Nov 26, 2007 at 01:56 AM

    Hello Bo,

    try like this: (see pseudo code below)

    Loop at Sales Docs.   "For every sales document
     CALL FUNCTION BAPI_SALESORDER_CREATEFROMDATA .....
    
      If success.   "sales order was created but not yet written to database
        CALL FUNCTION BAPI_BILLINGDOC_CREATEMULTIPLE .....
          If success.   "invoice was created but not yet written to database
           Commit Work.     "or use FM BAPI_TRANSACTION_COMMIT
          else.           "failed to create invoice
               Rollback Work.
          endif.
      Endif.
    Endloop.

    <b>Don't forget to reward points please.</b>

    Cheers,

    Sougata.

    Add a comment
    10|10000 characters needed characters exceeded

    • Thanks Rob, I overlooked that part.

      Bo,

      The logic as per my first post (now with Rob's correction) should work fine. I don't see how it would not work for your requirement. In the loop instead of calling the old BAPI call the new BAPI_SALESORDER_CREATEFROMDAT2.

      Cheers,

      Sougata.

      I reckon its not working because Bo is not rewarding us points! What do you say Rob? 😊

      Message was edited by:

      Sougata Chatterjee

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.