‎2006 Dec 19 7:20 AM
hi experts,
here i want to fetch 1st record from itab1 into itab3,
after that i want to fetch records from itab2 into itab3 where data depending on the 1st table.
records which belongs to that itab1 only should go and sit under itab1 record.
ex:
itab1 data: 123
234
345
itab2 data : 123-x
123-y
234-y
234-z
i want itab3 like below:
itab3: 123
123-x
123-y
234
234-y
234-z
can u please guide me in htis ...................
‎2006 Dec 19 7:25 AM
Hi,
use nested loops
loop at itab1
loop at itab2 where f1 = itab-f1
move-corresp. itab2 to itab3...
A.
‎2006 Dec 19 7:25 AM
Hi,
use nested loops
loop at itab1
loop at itab2 where f1 = itab-f1
move-corresp. itab2 to itab3...
A.
‎2006 Dec 19 7:26 AM
Hi,
loop at itab1.
move corresponding itab1 to itab3.
append itab3.
loop at itab2 where field1 = itab1-field1.
move corresponding itab2 to itab3.
append itab3.
endloop.
endloop.
‎2006 Dec 19 7:28 AM
try likethis
loop at itab1.
move-corresponding itab1 to itab3.
append itab3.
loop at itab2.
if itab2-f1 CS itab-f1.
move-corresponding itab2 to itab3.
append itab3.
endif.
endloop.
endloop.
regards
shiba dutta
‎2006 Dec 19 7:28 AM
loop at itab1.
itab3 = itab1.
append itab3
read table itab2 with key field1 = itab1-field1. "Header data in itab1 still there
itab3 = itab2.
append itab3.
clear: itab1, itab2, itab3.
endloop.
This should do it, award points if found helpful
‎2006 Dec 19 7:39 AM
Hi,
If for each record in itab1(say 123),there exists atleast one record in itab2(say 123-x),then
append lines of itab1 to itab3.
append lines of itab2 to itab3.
is sufficient.
Otherwise,
loop at itab1.
append itab1 to itab3.
loop at itab2 where f1 = itab-f1.
append itab2 to itab3.
endloop.
endloop.
‎2006 Dec 19 9:28 AM
try with this following code.
data:begin of itab1 occurs 0,
f1(4) type c,
f2(4) type c,
f3(4) type c,
end of itab1.
data:begin of itab2 occurs 0,
f1(5) type c,
f2(5) type c,
f3(5) type c,
f4(5) type c,
end of itab2.
data:begin of itab3 occurs 0,
f1(5) type c,
f2(5) type c,
f3(5) type c,
f4(5) type c,
f5(5) type c,
f6(5) type c,
end of itab3.
itab1-f1 = '123'. itab1-f2 = '234'.itab1-f3 = '345'.
append itab1. clear itab1.
itab2-f1 = '123-x'.itab2-f2 = '123-y'.itab2-f3 = '234-y'.itab2-f4 = '234-z'.
append itab2. clear itab2.
loop at itab1.
read table itab2 index sy-tabix.
itab3-f1 = itab1-f1.
itab3-f2 = itab2-f1.
itab3-f3 = itab2-f2.
itab3-f4 = itab1-f2.
itab3-f5 = itab2-f3.
itab3-f6 = itab2-f4.
append itab3.
clear itab3.
endloop.
loop at itab3.
write:/ itab3-f1, itab3-f2, itab3-f3,itab2-f4,itab3-f5,itab3-f6.
endloop.
helpful reward me.
‎2006 Dec 19 9:32 AM
hi,
check this.
data : begin of itab1 occurs 0. "itab with work area.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
endof itab1.
data : begin of itab2 occurs 0. "itab with work area.
key_field2 like ztable2-key_field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab2.
data : begin of itab_final occurs 0.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab_final.
LOOP AT ITAB1.
MOVE-CORRESPONDING TO ITAB1 to ITAB_FINAL.
READ TABLE ITAB2 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
READ TABLE ITAB3 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
append itab_final.
clear itab_final.
endloop.Regards
Anver