‎2008 Aug 27 10:18 AM
hie guys
i want to modify an entry in an internal table with that of another in another internal table. i have the code below but it creates another entry.
IntTab1 - 001 Isaac Prince
IntTab2 - 001 Isaac Prince 1000
loop at intTab1.
loop at intTab2 index sy-tabix.
modify intTab1 from intTab2.
endloop.
endloop.
i thot specifying the key field would help but i get a syntax error when i do so that i must specify the index.
loop at intTab1.
loop at intTab2 where key = intTab1-key.
modify intTab1 from intTab2.
endloop.
endloop.
hw can i then modify the entry in an internal table with values from another internal table??
‎2008 Aug 27 10:21 AM
hi prince
IntTab1 - 001 Isaac Prince
IntTab2 - 001 Isaac Prince 1000
loop at intTab1.
loop at intTab2 index sy-tabix.
modify intTab1 from intTab2 transporting fields * addition.
endloop.
endloop.
Regards
Deva
‎2008 Aug 27 10:21 AM
hi prince
IntTab1 - 001 Isaac Prince
IntTab2 - 001 Isaac Prince 1000
loop at intTab1.
loop at intTab2 index sy-tabix.
modify intTab1 from intTab2 transporting fields * addition.
endloop.
endloop.
Regards
Deva
‎2008 Aug 27 10:24 AM
intTab1 and intTab2 has same number of records and the corresponding lines have the same key ?
I guess you can do it by:
loop at intTab1.
loop at intTab2 index sy-tabix.
modify intTab1 index sy-tabix from intTab2.
endloop.
endloop.
‎2008 Aug 27 10:31 AM
Hi,
try this way:
loop at IntTab1.
read table IntTab2 into wa_IntTab2 index sy-tabix.
modify IntTab1 index sy-tabix from wa_IntTab2.
endloop.
Hope this will help.
Regards,
Swarna Munukoti.
Edited by: Swarna Munukoti on Aug 27, 2008 11:31 AM
‎2008 Aug 27 10:32 AM
hi ...
please check it.
F1 F2 F3 F4
IntTab1 - 001 Isaac Prince
IntTab2 - 001 Isaac Prince 1000
data: L_tabix type sy-tabix.
loop at intTab2 in wa_itab2.
read table intTab1 into wa_ITAB1 with key F1 = wa_itab2 -F1
F2 = wa_itab2-F2
F3 = wa_itab2-F3.
if sy-subrc =0.
L_tabix = sy-tabix.
wa_itab1-F4 = wa_ITAB2-F4.
modify intTab1 from wa_itab1 index l_tabix transporting F4.
endif.
endloop.
‎2008 Aug 27 10:34 AM
Do this way...
data: l_tabix like sy-tabix.
loop at intTab1.
l_tabix = sy-tabix.
read table intTab2 with key <field> = inttab1-<field>.
if sy-tabix = 0.
move required data of inttab2 to inttab1 fields.
modify inttab1 index l_tabix.
endif.
endloop.
‎2008 Aug 27 10:36 AM
Hi,
loop at IntTab1 into wa_IntTab1.
read table IntTab2 into wa_IntTab2 with key field1 = wa_IntTab1-field1.
if sy-subrc eq 0.
modify IntTab1 from wa_IntTab2 index sy-tabix.
endif.
endloop.
hope this helps.
thanx.
Edited by: Dhanashri Pawar on Aug 27, 2008 11:37 AM
‎2008 Aug 27 10:52 AM
How can u read the table 2 without specyfying a key.
AS Subankar did,
loop at tab 1.
then use read statement and then modify tab2 based on read index.
‎2008 Aug 27 11:22 AM
Hi Prince,
Use the code below for the same problem and you will surely get it.
data: begin of IntTab1 occurs 0,
va1(10) type c,
va2(10) type c,
va3(10) type c,
end of IntTab1.
data IntTab2 like table of IntTab1 with header line.
IntTab1-va1 = 'Isaac'.
IntTab1-va2 = 'Prince'.
IntTab2-va1 = 'Isaac2'.
IntTab2-va2 = 'Prince2'.
IntTab2-va3 = '10002'.
append IntTab1.
append IntTab2.
loop at IntTab1.
write : /, IntTab1-va1,
IntTab1-va2,
IntTab1-va3.
endloop.
loop at Inttab2.
write : /, IntTab2-va1,
IntTab2-va2,
IntTab2-va3.
endloop.
loop at intTab1.
modify intTab1 from intTab2.
endloop.
loop at IntTab1.
write : /, IntTab1-va1,
IntTab1-va2,
IntTab1-va3.
endloop.
Regards,
Amit.