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

How to update table 2 based from table 1.

aris_hidalgo
Contributor
0 Likes
886

Hello experts,

I have 2 Z tables and I need to update table 2 based from table 1. Tables 1 & 2 have 2 fields which are the same namely

KUNNR and CDSEQ. Now, I want to update the ZADDRESS field of table 2 based from table1-zaddress where table1-kunnr and

table1-cdseq is equal to table2-kunnr and table2-cdseq.

Again, thank you guys and take care!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
766

hi

the only way out would be:

1. use internal table and move the content based on the entries and selection criteria mentioned and say

modify dbtab from itab.

2. there are specific events associated with each tableu can make use of that

Reward points if it helps

regards

Gunjan

Hello experts,

I have 2 Z tables and I need to update table 2 based from table 1. Tables 1 & 2 have 2 fields which are the same namely

KUNNR and CDSEQ. Now, I want to update the ZADDRESS field of table 2 based from table1-zaddress where table1-kunnr and

table1-cdseq is equal to table2-kunnr and table2-cdseq.

Again, thank you guys and take care!

4 REPLIES 4
Read only

Former Member
0 Likes
767

hi

the only way out would be:

1. use internal table and move the content based on the entries and selection criteria mentioned and say

modify dbtab from itab.

2. there are specific events associated with each tableu can make use of that

Reward points if it helps

regards

Gunjan

Read only

Former Member
0 Likes
766

DATA: itab contains three fields kunnr cdseq and zaddress,

wa_itab type line of itab

select kunnr

cdseq

zaddress

from table1

into itab.

loop at itab into wa_itab

update table2 set zaddress = wa_itab-address

where kunnr = wa_itab-kunnr

cdseq = wa_itab-cdseq

endloop.

Read only

Former Member
0 Likes
766

Hi Viraylab,

Try this code.

DATA : begin of wa,

zaddress TYPE ztable1-zaddress,

end of wa.

SELECT SINGLE * FROM ztable1

INTO corresponding fields of wa

WHERE KUNNR = Ztable2-kunnr and

CDSEQ = Ztable2-CDSEQ.

UPDATE ztable2 FROM wa.

Regards,

Mukesh Kumar

Read only

Former Member
0 Likes
766

Hi Viraylab,

Please see this code.

<b>Report :</b>

data : itab type table of table1 with header line,

jtab type table of table2 with header line,

wa like line of itab.

select * from table1 into table itab.

select * from table2 into table jtab.

loop at itab into wa.

read table jtab with key kunnr = itab-kunnr and

cdseq = itab-cdseq.

if sy-subrc eq 0.

jtab-address = itab-address.

modify jtab.

endif.

endloop.

modify table2 from jtab.

If found helpful, please do reward.