Rollback - Make to Order

saurabhabhsaurabhabh Member Posts: 17
Hi,

I have a situation where in i have modified the Codeunit-83 (Sales-Quote to Order(Yes/No).
I have some customized code which makes use of the SalesHeader Number that the method
SalesQuoteToOrder.GetSalesOrderHeader(SalesHeader2);
fills in the 'SalesHeader2'.

What i want is that if the customization that i have done fails, then i want to rollback the entire above transaction.
i.e
- No new Sales Order should be created.
- Sales Quote should not be deleted and everything should be restored to the earlier state.

I did try to make the below change. But it doesn't work .
SalesQuoteToOrder.RUN(Rec);
SalesQuoteToOrder.GetSalesOrderHeader(SalesHeader2);
//Purpose : Make use of the SalesHeader Number set in SalesHeader2 and do some processing. 

   retVal := saurabh.doProcessing(Rec, SalesHeader2);

IF (retVal = 0) THEN //Processing success
  BEGIN
    COMMIT;
    MESSAGE(Text001,"No.",SalesHeader2."No.");
  END
ELSE //Processing Failed
  BEGIN
  //The ERROR('') will quietly rollback the data changes,
  //and the ASSERTERROR will capture the error, allowing the code execution to continue.
    ASSERTERROR ERROR('');
    MESSAGE(Text002,"No.",SalesHeader2."No.");
  END;

I think that s because a commit happens in the code unit
SalesQuoteToOrder.RUN(Rec);

Please let me know how to rollback the entire thing.
Sign In or Register to comment.