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: 
Read only

ROLLBACK database tables

Former Member
0 Likes
832

Hi Friends,

I need some help on Rollback

I have a header table and an Item table

First data is inserted in Header table and then the related item records are updated in Item table

Assume a scenario where the Header records gets updated successfully and the item records

insertion fails for some reason

So in this case the header records should be rolledback , please give some inputs on this

Thanks

Chandra

Edited by: Chandrasekhar Jagarlamudi on May 29, 2009 2:10 PM

5 REPLIES 5
Read only

ThomasZloch
Active Contributor
0 Likes
732

Your header and item updates would be one LUW (logical unit of work). Once everything is done without errors, you send a COMMIT WORK. Before that, you can use ROLLBACK WORK to undo the changes to the header table, should there be a problem with the items update.

Thomas

Read only

0 Likes
732

Thanks Thomas

Can you please let me know how can we make the 2 tables as one LUW as i am new to this

Do we have to maintain it at database level or program level

Thanks

Chandra

Read only

0 Likes
732

The keywords I mentioned are ABAP statements, the LUW logic is inside your program code. Check the online help for these keywords in the ABAP editor, it's all being explained there.

Thomas

Read only

Former Member
0 Likes
732

This message was moderated.

Read only

Firoz_Ashraf
Contributor
0 Likes
732

Hi,

You may write your code in the following fashion:

 
INSERT zhead FROM TABLE i_zhead.
IF sy-subrc EQ 0.
   INSERT zitem FROM TABLE i_zitem.
   IF sy-subrc NE 0.
      ROLLBACK WORK.
   ENDIF.
ENDIF.

Regards,

Firoz.