Roll back Issue
In my program i am using 2 BAPIs one by one.
First i am using BAPI_SALESORDER_CHANGE if this is sucess i am doing goods movement using BAPI_GOODSMVT_CREATE
if goods movement is unsucess i have to roll back both the processes.
Please advice me how can i roll back Sales order changes also.
nagaraj kumar nishtala replied
No there is no auto commit on the sales order change . Once the sales order is committed, you cannot roll back.Try like this.
1>First get the data from vbak, vbap table the record which you are going to change.if single reocrd store in work area if multiple records store in internal table (itab)
2>call the bapi "BAPI_SALESORDER_CHANGE" FUNCTION MODULE
3>Read the return structure with message type = 'S'. if yes then call "BAPI_TRANSACTION_COMMIT"
4>Call the bapi "BAPI_GOODSMVMT_CREATE" .
5>Read the return structure with message type = 'S'. if yes then call "BAPI_TRANSACTION_COMMIT" ELSE call "BAPI_TRANSACTION_ROLLBACK AND t
Read the record from the internal table (itab) which you have retrievd from the VBAK, VBAP table, You will have the old values and now call the bapi BAPI_SALESORDER_CHANGE and pass the values and then commit it with BAPI_TRANSACTION_COMMIT.
Now the sales order will be back with older values.