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

program to update 2 database tables

former_member391265
Participant
0 Likes
807

Hi all

I have requirement where i need to update records in  2 database tables.

My first doubt is can we update 2 database tables at same time with code..

or if not..how do we do it one after another??

and suppose if i am doing database update 1 after another//

if first database table update is not happened, i want to stop the database update of second table???how can i achieve it?

and if first database table update is done successfully. 2nd dbtable also should get updated...

Thanks

3 REPLIES 3
Read only

Former Member
0 Likes
752

Are these Z tables?

If not, then think very hard before doing.

If they were however say za and zb.

A simple logic of:

Lock za

Lock zb

Update za from waza

update zb from wazb

If either fail roll back

else commit

unlock za

unlock zb

could be very reasonable.  That puts za and zb in the same LUW.

Would you please explain in more detail what you fully need.

Neal

Read only

former_member193464
Contributor
0 Likes
752

I hope these are custom tables...
use update/modify statement (depending on your requirement)it would return a sy-subrc if it is 0 go ahead and update the second database table, if not then roll back , if both returns a sy-subrc as 0 then only commit work else put a roll back.
look for abap help F1 for how to use update/modify syntaxes and uses.

Read only

Former Member
0 Likes
752

Hi,

You can update two or 'N' database tables at the same time.

For the other Query please refer Neal's or Manoj's Answer.

BR,

Ankit.