Application Development 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: 

Roll back Issue

kishorepallapothula
Participant
0 Kudos

Hi ,

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.

Thanks,

Kishore

1 ACCEPTED SOLUTION

former_member404244
Active Contributor
0 Kudos

Hi,

call BAPI_TRANSACTION_COMMIT after the bapi_goodsmvmt_create function module.. Do like this

First call BAPI_SALESORDER_CHANGE

read the return internal table. If ypu find everything sucsess then only call

BAPI_GOODSMVT_CREATE function module and then read the return structre

if everything is success then only call the fm BAPI_TRANSACTION_COMMIT .

Now the commit will work for both the function modules when there is no error.

Regards,

Nagaraj

8 REPLIES 8

Former Member
0 Kudos

if all wnet sucessful, you can do a BAPI_TRANSACTION_COMMIT,

if some errors occured, do BAPI_TRANSACTION_ROLLBACK.

0 Kudos

Hi Florian,

I am using commit and rollback. In one of the scenarion Sales order change is successful and Goods movment is unsuccessful so i used rollback but it only rollback the goods movement but not rollbacked sales order change.

Please advice.

Thanks,

Kishore

0 Kudos

if you are using a BAPI, you shall NOT use COMMIT WORK or ROLLBACK WORK, but instead make use of the FM´s i mentioned above.

I dont really wonder that you got issues with a simple commit or rollback statement.

0 Kudos

Hi Florian,

I am using BAPI_TRANSACTION_COMMIT and BAPI_TRANSACTION_ROLLBACK.

Thanks,

kishore P

0 Kudos

ah ok, sorry wasnt aware of that since you just were talking about commit and riollback :).

BTW i just had a look at the documentation of BAPI_SALESORDER_CHANGE.

It is clearly stating there that there is NO commit in place and that you have to do it for yourself from the calling program.

May it be that this happens when you debug it? There is some auto commit when debugging, tho i cant really specify it more detailed.

Edited by: Florian Kemmer on Jun 7, 2011 10:15 AM

former_member404244
Active Contributor
0 Kudos

Hi,

call BAPI_TRANSACTION_COMMIT after the bapi_goodsmvmt_create function module.. Do like this

First call BAPI_SALESORDER_CHANGE

read the return internal table. If ypu find everything sucsess then only call

BAPI_GOODSMVT_CREATE function module and then read the return structre

if everything is success then only call the fm BAPI_TRANSACTION_COMMIT .

Now the commit will work for both the function modules when there is no error.

Regards,

Nagaraj

0 Kudos

Hi Nagaraj,

Thanks for your post.

The problem is with roll back ... If i roll back after second bapi, both the bapis should be rolled back, which is not happening here latest bapi only getting rolled back that is goods movment bapi.

I have a question that bapi_salesorder_change having auto commit ?

Please advice if you have any idea.

Thanks,

Kishore P

0 Kudos

Hi Kishore,

No there is no auto commit on the sales order change . Once the sales order is committed, you cannot roll back.Try like this.

steps

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.

Regards,

Nagaraj