11-20-2007 5:00 AM
suppose both table have entries.
iist itab has 3 column ,2 contain 5 column
2 column are common
i want to pick up one column that is not prasent in second itab and 2 columns from 2nd itab which are not present in ist itab
and two column athat are common i can also pick with these column.
now i have 5 columns based on this i want to fatch data form database how
suppose in 2nd itab have multiple enteries corresponding one record in 1st itab
how we procedd we cant use read becuase it always pick single record.
11-20-2007 6:46 AM
Hi,
You cannot use two internal tables in a select query. Instead move the records from the two tables into a single table and use this table in selecting data from the DB.
Hope i got your query right!
Cheers,
11-20-2007 8:12 AM
Hi
You can use APPEND LINES OF itab1 TO itab2, when there is no condition and the structure of the 2 internal tables are the same.
If you have to join 2 internal tables upon some condition, then Loop is necessary.without looping it is not possible.
11-20-2007 9:34 AM
you have to program a nested loop
sort itab by ....
loop at itab1 into wa1.
read itab2 into wa2
with key ...binary search
wa3-col1 = ...
....
wa3-col5 =
append wa3 to itab3.
endloop
The new table itab3 is the join.
Siegfried
11-27-2007 3:24 PM
sort itab by ....
loop at itab1 into wa1.
read itab2 into wa2
with key ...binary search
wa3-col1 = ...
....
wa3-col5 =
append wa3 to itab3.
endloop
in your answer above where is loop on itab3 is it correct
11-27-2007 4:24 PM
sort itab2 by ....
loop at itab1 into wa1.
read itab2 into wa2
with key ... binary search
if ( sy-subrc eq 0 ).
wa3-col1 = ...
....
wa3-col5 =
append wa3 to itab3.
endif.
endloop.
the resulting table itab3 in something like an inner join of itab1 and itab2.
Outer joins would mean that itab3 has also lines which are only in one internal table and not in both. They are a bit more complicated, but I think you need the
inner join-type.
There is no loop an itab3, it is built by the appends.
Siegfried