2007 Feb 23 4:44 AM
How to fetch the data from 3 internal tables into another interna table?
Hi,
1. Declare a final itab with all the fields and move the values of one db table to this
2. get the date from 2 tables
3. sort them
4. loop at final itab
5. read statement for each table and use binary search
6. modify final itab transporting the values
7.endloop.
Regards
Shiva
2007 Feb 23 4:48 AM
There will be atleast one key fields in 3 internal tables based on this you can write a logic.
eg:
loop at itab1.
move-corresponding itab1 to itfinal.
read table itab2 with key field1 = itab1-field1.
if sy-subrc = 0.
move-corresponding itab2 to itfinal.
endif.
read table itab3 with key field1 = itab1-field1.
if sy-subrc = 0.
move-corresponding itab3 to itfinal.
endif.
append itfinal.
clear itfinal.
endloop.
now the itfinal table contains the records from 3 tables.
2007 Feb 23 4:49 AM
Hi Balu,
Suppose i have three internal tables ITAB1, ITAB2, ITAB3 into ITAB with a key field1.
do the following:-
loop at ITAB1.
clear ITAB.
move correspond ITAB1 to ITAB.
read table ITAB2 with key field1 = ITAB1-key.
move correspond ITAB2 to ITAB.
read table ITAB3 with key field1 = ITAB1-key.
move correspond ITAB3 to ITAB.
append ITAB.
endloop.
after this you will get all the data in ITAB internal table.
Or Else...
if there are common fields in the 3 internal tables , the use
sort itab1 by field1.
sort itab1 by field2.
sort itab1 by field3.
loop at itab1.
move-corresponding itab1 to it_final.
read table itab2 with key field1 = itab1-field1 binary search.
if sy-subrc eq 0.
move-corresponding itab2 to it_final.
endif.
read table itab3 with key field1 = itab1-field1 binary search.
if sy-subrc eq 0.
move-corresponding itab3 to it_final.
endif.
append it_final.
clear it_final.
endloop.
Regards,
Priyanka.
2007 Feb 23 4:51 AM
2007 Feb 23 4:51 AM
Hi,
You need to
Loop at ITAB1.
read ITAB2 with key <field2> = <itab1-field1>.
read ITAB2 with key <field3> = <itab1-field1>.
itab4-field1 = itab1-field1.
itab4-field2 = ita21-field2.
itab4-field3 = itab3-field3.
...
append itab4.
clear itab4.
endloop.
Internal table ITAB4 contains the combined data of all the three tables itab1,itab2,itab3.
Regards,
Saumya
2007 Feb 23 5:17 AM
Hi,
1. Declare a final itab with all the fields and move the values of one db table to this
2. get the date from 2 tables
3. sort them
4. loop at final itab
5. read statement for each table and use binary search
6. modify final itab transporting the values
7.endloop.
Regards
Shiva
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |