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: 

How to update the tables either in its entirety or not at all

Former Member
0 Kudos

We want update more than two tables at one time,for example we code following:

update A set ***

update B set ***

we first update A, but sometimes B can not be updated sucessful,

How to update A&B tables in its entirety? Or, if any one of these tables can not be updated sucessful,two talbes don't update at all.

Thank you very much?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Thank you!

But when I only use ' update A*** ' (not commit work),the table A have been updated.

if the table B can not been updated sucessful, do we need delete the information from A?

Could you pls give me a example code?Thank you very much.

5 REPLIES 5

Former Member
0 Kudos

Hi susi,

Use COMMIT WORK after your update statements..

Best of luck,

Bhumika

Former Member
0 Kudos

hi,

You want to update or not update at all that means either Update or rollback.

So Put A COMMIT WORK statement after the update starement.

It will either fully update or Automatically Rollback the whole

Processing.

Regards

Sumit Agarwal

Former Member
0 Kudos

Thank you!

But when I only use ' update A*** ' (not commit work),the table A have been updated.

if the table B can not been updated sucessful, do we need delete the information from A?

Could you pls give me a example code?Thank you very much.

0 Kudos

after the first update statement...check for sy-subrc..

if sy-subrc eq 0.

use the second update.

if sy-subrc NE 0.

restore the original value of the first table field using update statement only..

endif.

Former Member
0 Kudos

thank you very much,I find the solution:

update A ***.

if sy-subrc = 0.

update B****.

if sy-subrc = 0.

commit work.

else.

rollback work.

endif.

else.

rollback work.

endif.