2008 Sep 09 12:21 PM
Hi,
How can I join 3 internal table into one internal tables?
2008 Sep 09 12:24 PM
sort itab1 by <fields>.
sort itab2 by <fields>.
sort itab3 by <fields>.
Loop at itab1.
read table itab2 with key <field> = itab1-<field>.
if sy-subrc = 0.
move itab2 data it_final.
endif.
read table itab3 with key <field> = itab1-<field>.
if sy-subrc = 0.
move itab3 data it_final.
endif.
move itab1 data it_final.
Endloop.
Hi,
How can I join 3 internal table into one internal tables?
2008 Sep 09 12:23 PM
If you want to join 3 internal tables then the nested loops is the only solution.
However constraint with the nested loop will be you should have the mapping primary key for the nested loops.
Regards,
Kunjal
2008 Sep 09 12:24 PM
sort itab1 by <fields>.
sort itab2 by <fields>.
sort itab3 by <fields>.
Loop at itab1.
read table itab2 with key <field> = itab1-<field>.
if sy-subrc = 0.
move itab2 data it_final.
endif.
read table itab3 with key <field> = itab1-<field>.
if sy-subrc = 0.
move itab3 data it_final.
endif.
move itab1 data it_final.
Endloop.
2008 Sep 09 12:25 PM
Check this-
SELECT v1~vbeln AS vbeln
v2~posnr AS posnr
v2~matnr AS matnr
v2~werks AS werks
v2~meins AS meins
v2~lgort AS lgort
v2~kwmeng AS kwmeng
v3~lfsta AS lfsta
INTO TABLE t_items
FROM vbak AS v1
INNER JOIN vbap AS v2
ON v1vbeln = v2vbeln
INNER JOIN vbup AS v3
ON v2vbeln = v3vbeln
AND v2posnr = v3posnr
WHERE v1~vbeln IN s_vbeln
AND v1~auart IN r_auart "Sales order type should be 'ZOR'
AND v1~lifsk = ' ' "No delivery block
AND v1~vkorg IN s_vkorg "Sales organization
AND v1~vdatu IN s_vdatu "Requested delivery date
AND v2~abgru = ' ' "No reason of rejection
AND v2~lgort = c_lgort "Storage location = 1000
AND v2~vstel IN s_vstel "Shipping point
AND v3~lfsta <> 'C'. "Itme should be delivered
Regards,
Aparna Gaikwad
2008 Sep 09 12:29 PM
Let us assume that u have three table as
it_table1,
it_table2,
it_table3 as three tables
and
wa_table1,
wa_table2,
wa_table3 as work areas
and you have to pass these three table data to it_final table which has wa_final as work area.
IMPORTANT THING IS ALL THE THREE HAVE SAME STRUCTURES.
CLEAR WA_TABLE1.
LOOP AT IT_TABLE1 INTO WA_TABLE1.
APPEND WA_TABLE1 TO IT_FINAL.
CLEAR WA_TABLE1.
ENDLOOP.
CLEAR WA_TABLE2.
LOOP AT IT_TABLE2 INTO WA_TABLE2.
APPEND WA_TABLE2 TO IT_FINAL.
CLEAR WA_TABLE2.
ENDLOOP.
CLEAR WA_TABLE3.
LOOP AT IT_TABLE3 INTO WA_TABLE3.
APPEND WA_TABLE3 TO IT_FINAL.
CLEAR WA_TABLE3.
ENDLOOP.
IF THREE TABLE STRUCTURE ARE DIFFERENT AND THEN U HAVE TO LOOK FOR COMMON FIELDS IN THREE INTERNAL TABLES
2008 Sep 09 12:30 PM
Let us assume that u have three table as
it_table1,
it_table2,
it_table3 as three tables
and
wa_table1,
wa_table2,
wa_table3 as work areas
and you have to pass these three table data to it_final table which has wa_final as work area.
IMPORTANT THING IS ALL THE THREE HAVE SAME STRUCTURES.
CLEAR WA_TABLE1.
LOOP AT IT_TABLE1 INTO WA_TABLE1.
APPEND WA_TABLE1 TO IT_FINAL.
CLEAR WA_TABLE1.
ENDLOOP.
CLEAR WA_TABLE2.
LOOP AT IT_TABLE2 INTO WA_TABLE2.
APPEND WA_TABLE2 TO IT_FINAL.
CLEAR WA_TABLE2.
ENDLOOP.
CLEAR WA_TABLE3.
LOOP AT IT_TABLE3 INTO WA_TABLE3.
APPEND WA_TABLE3 TO IT_FINAL.
CLEAR WA_TABLE3.
ENDLOOP.
IF THREE TABLE STRUCTURE ARE DIFFERENT AND THEN U HAVE TO LOOK FOR COMMON FIELDS IN THREE INTERNAL TABLES
2008 Sep 09 12:33 PM
2008 Sep 09 12:36 PM
Hi Nilesh,
Read will only be possible if you are sure that the tables you are reading contains only 1 record otherwise you will not get the complete data...
In case of multiple entries LOOP is the best possible option available.
Regards,
Kunjal
2008 Sep 09 12:50 PM
>
> Hi friend,
> Rather joining the internal table through the loops which may affect the performance, wat u can do is use read statement with for all entries,
> read itab1 into wa_itab for all entries in itab2 where <cond>
Wrong syntex with read.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |