10-14-2006 8:16 PM
Hello,
i have to join the whole content of a table with the content of a aggregated table. i "moved" the content of the 2 dictionary tables into 2 internal tables and i want to join these 2 internal tables now.
first of all, is it generally possible to join 2 internal tables, for example with a read or loop statement?!
at second, i know how i would solve the problem in oracle 10g, but it looks like that open-sql supports not the same features like orcale. knows anyone of you how i can rebuild the following oracle statement in abap.
#####
select a.id, a.col1, b.col2
from table_a as a, (select id, sum(col2) as col2 from table_c group by id) as b where a.id = b.id order by 1
#####
thx
10-14-2006 8:24 PM
It's best to "join" two internal tables by looping through the first and reading the second using a binary search.
Rob
10-14-2006 9:50 PM
Hello Markus
ABAP open sql ahould be something like
select aid acol1 sum( b~col2 )
from table_a as a
join table_c as b
on aid = bid
group by b~id
not sure abour the order by; don't know oracle syntax exactly.
Try!
Regards,
Clemens
10-16-2006 10:30 AM
A good programming practice is use a join query as stated earlier.
Else you can use field symbols to define the structure. Then assign the data to them. This is useful if you know dynamic programming.
Regards,
Sandeep Josyula
10-16-2006 10:34 AM
Hi Markus,
Say we have internal tables itab1 and itab2.
The link between these two tables is say, field1.
Then you should do something like this:
loop at itab1.
read table itab2 with key field1 = itab1-field1.
if sy-subrc = 0.
move-correspoding itab1 to it_final.
move-correspoding itab2 to it_final.
append it_final.
clear it_final.
endif.
endloop.
Regards,
Ravi
10-16-2006 10:38 AM
The below should give you the result
SELECT AID ACOL1 sum(B~COL2) INTO TABLE ITAB
FROM TABLE_A AS A INNER JOIN TABLE_B AS B
ON AID = BID
GROUP BY AID ACOL1
ORDER BY A~ID.