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

Modify and Delete Statements rollback

Former Member
0 Kudos
1,868

Hi,

I have an database update requirement . I have to delte few row from a ztable and insert/modify new rows. My requirement is if second insert.modify fails then first delete should be rolled back. Please let me know how to do this.

Thanks in advance.

Madhu

1 ACCEPTED SOLUTION

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
723

I dont think you need to code anything special for this.

A simple ROLLBACK WORK will reverse all the changes & end the DB LUW. If the UPDATE / DELETE fails do a ROLLBACK WORK.

Just remember not to use COMMIT WORK after each DB update / delete statement.

BR,

Suhas

PS: As suggested by Florian you should go through this SAP documentation on Database LUW: [http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/content.htm]

Edited by: Suhas Saha on Mar 30, 2010 12:26 PM

5 REPLIES 5

Former Member
0 Kudos
723

LUW - logical unit of work, would be your keyword for a search on this.

Former Member
0 Kudos
723

hi

Chcek

1st insert

if sy-subrc = 0.

2nd insert

if sy-subrc <> 0.

rollback work.

endif.

endif.

Former Member
0 Kudos
723

Hi,

not sure :)..

but..

Have a copy of first before u insert or delete..

then when next delete fails then insert or delete the copied data into table..

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
724

I dont think you need to code anything special for this.

A simple ROLLBACK WORK will reverse all the changes & end the DB LUW. If the UPDATE / DELETE fails do a ROLLBACK WORK.

Just remember not to use COMMIT WORK after each DB update / delete statement.

BR,

Suhas

PS: As suggested by Florian you should go through this SAP documentation on Database LUW: [http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/content.htm]

Edited by: Suhas Saha on Mar 30, 2010 12:26 PM

Former Member
0 Kudos
723

solved