2007 Feb 08 3:33 AM
hey
i have a case where there are 2 internal tables and i want to put all this data into one internal table. i need to write the code for it.
internal table 1 : F1 F2 F3 F4
internal table 2: F1 F2 F5 F6 F7 F8 F9
internal table 3 should have F1 to F9 with a condition that internal table1-F1 = internal table 2-F1 and internal table 1 - F2 = internal table 2-F2.
Please help me with this.
thanks
Laura.
2007 Feb 08 3:37 AM
Hi,
Please try this.
LOOP AT ITAB1.
LOOP AT ITAB2 WHERE F1 = ITAB1-F1
AND F2 = ITAB1-F2.
MOVE-CORRESPONDING ITAB1 TO ITAB3.
MOVE-CORRESPONDING ITAB2 TO ITAB3.
APPEND ITAB3.
ENDLOOP.
ENDLOOP.
Please check the syntax.
Regards,
Ferry Lianto
2007 Feb 08 3:37 AM
Hi,
Please try this.
LOOP AT ITAB1.
LOOP AT ITAB2 WHERE F1 = ITAB1-F1
AND F2 = ITAB1-F2.
MOVE-CORRESPONDING ITAB1 TO ITAB3.
MOVE-CORRESPONDING ITAB2 TO ITAB3.
APPEND ITAB3.
ENDLOOP.
ENDLOOP.
Please check the syntax.
Regards,
Ferry Lianto
2007 Feb 08 4:16 AM
2007 Feb 08 4:17 AM
2007 Feb 08 4:18 AM
2007 Feb 08 4:20 AM
2007 Feb 08 4:21 AM
Sort itab1 by F1 F2.
sort itab2 by F1 F2.
Loop at itab1 into wa1.
read table itab2 into wa2 with key F1 = wa1-F1 F2 = wa1-F2 binary search.
if sy-subrc = 0.
move corresponding wa2 to wa_final.
wa_final-F3 = wa1-F3.
wa_final-F4 = wa1-F4.
append wa_final to itab3.
endif.
endloop.
2007 Feb 08 3:21 PM
thanks ferry
problem solved. i have assigned points to all helpful answers.
Laura.
2007 Feb 08 3:45 AM
HI,
use the following code.
LOOP AT ITAB1 into WA1.
LOOP AT ITAB2 INTO WA2 WHERE f1 = WA1-f1 f2 = wa1-f2.
MOVE-CORRESPONDING WA1 to WA3.
MOVE-CORRESPONDING WA2 to WA3.
APPEND WA3 to ITAB3.
ENDLOOP.
ENDLOOP.
Regards,
Sesh
Message was edited by:
Seshatalpasai Madala
2007 Feb 08 3:47 AM
Hi,
loop at itab1 into wa1.
move-corresponding wa1 to wa3.
loop at itab2 into wa2 where f1 = wa1-f1 and f2 = wa1-f2.
move-corresponding wa2 to wa3.
append wa3 to itab3.
endloop.
endloop.
2007 Feb 08 3:48 AM
Hi,
loop at itab3.
read table itab1 with key f1 = itab2-f1 and
f2 = itab2-f2.
if sy-subrc = 0.
itab3-f1 =itab1-f1.
.
.
.itab3-f4 = itab1-f4.
read table itab2 with key f1 = itab1-f1 and
f2 = itab1- f2.
itab3 -f5 = itab2-f5.
.
.
itab3-f9 = itab2-f9.
endif.
endloop.
2007 Feb 08 3:49 AM
Try this code:
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY F1 = ITAB1-F1
AND F2 = ITAB1-F2.
IF sy-subrc = 0.
MOVE-CORRESPONDING ITAB1 TO ITAB3.
MOVE-CORRESPONDING ITAB2 TO ITAB3.
APPEND ITAB3.
CLEAR ITAB3.
ENDIF.
ENDLOOP.
ENDLOOP.
2007 Feb 08 3:51 AM
Hi,
do like this
sort itab2.
LOOP AT ITAB1.
read table ITAB2 with key F1 = ITAB1-F1
AND F2 = ITAB1-F2
binarysearch.
if sy-subrc = 0.
ITAB3 = ITAB1.
APPEND ITAB3.
else.
ITAB3 = ITAB1.
APPEND ITAB3.
ITAB3 = ITAB2.
APPEND ITAB3.
endif.
endloop.
regards
Shiva