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: 

move from one itab to other

Former Member
0 Kudos

hi all ,i have a itab1 in which i have records like this

belnr hkont sgtxt lifnr amt_c amt_d

220005 1803 test k001

220006 1804 test k001

220007 1805 test k001 in another itab2 we have

hkont amt_c amt_d

1803 1000

1804 2500

1805 900

and i want to move amt_c and amt_d in to itab1 acc to hkont field and output should be like this

belnr hkont sgtxt lifnr amt_c amt_d

220005 1803 test k001 1000

220006 1804 test k001 00 2500

220007 1805 test k001 900

can anybody help.

points wil be rewarded surely.

7 REPLIES 7

Former Member
0 Kudos

former_member189629
Active Contributor
0 Kudos

Sarabjit,

Use the below code for ref...

loop at itab1.

itab3-belnr = itab1-belnr.

itab3-hkont = itab1-hkont.

itab3-sgtxt = itab1-sgtxt.

itab3-lifnr = itab1-lifnr.

read table itab2 with key hkont = itab1-hkont.

if sy-subrc = 0.

itab3-amt_c = itab2-amt_c.

itab3-amt_d = itab2-amt_d.

endif.

append itab3.

clear itab3.

endloop.

Reward if helpful,

Karthik

Former Member
0 Kudos

HI,

Loop at your first internal table then read the second one after that assign the amount to first internal table fiedl.then modify the first internal table.

EX;

Loop at itab into wa_itab.

read itab1 into wa2 with key hkont = wa_itab-hkont.

if sy-subrc eq o.

wa_itab-amount = wa2-amount.

endif.

modify itab from wa_itab.

clear: wa_itab,

wa2.

endloop.

Former Member
0 Kudos

Hi,

Try this,

Loop at itab1.

read table itab2 with key hkont = it1-hkont.

MOVE-CORRESPONDING itab2 TO itab1.

endloop.

Regards,

Padmam.

Former Member
0 Kudos

Hi

Loop at itab1.

read table itab2 with key hkont = itab1-hkont.

if sy-subrc = 0.

itab1-amt_c = itab2-amt_c.

endif.

modify itab1.

clear itab1.

endloop.

Former Member
0 Kudos

for this u hav to take a third internal table with fields which u want in output..

this table will hav fields belnr hkont sgtxt lifnr amt_c amt_d

then code as per the following algo..

loop at the itab1

read table itab2 wid key hkont

itab3-belnr = itab1-belnr

--

" fill all the cols of this itab3

--

itab3-amt_c = itab2-amt_c --

endloop.

Then ull get the reqd data in itab3..it ll surely work

reward if it works out

Former Member
0 Kudos

Hi,

Do this way

loop at itab1.

read table itab2 with key hkont = itab1-hkont.

if sy-subrc = 0.

itab1-amt_c = itab2-amt_c.

itab1-amt_d = itab2-amt_d.

modify itab1.

endif.

endloop.