‎2010 Mar 30 7:48 AM
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
‎2010 Mar 30 7:55 AM
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
‎2010 Mar 30 7:53 AM
LUW - logical unit of work, would be your keyword for a search on this.
‎2010 Mar 30 7:54 AM
hi
Chcek
1st insert
if sy-subrc = 0.
2nd insert
if sy-subrc <> 0.
rollback work.
endif.
endif.
‎2010 Mar 30 7:55 AM
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..
‎2010 Mar 30 7:55 AM
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
‎2010 Mar 30 11:59 AM