Skip to Content

Join two dynamic internal tables represented by symbolic links

Apr 07 at 06:21 AM


avatar image


I need to loop through two internal tables connected with a key field (inner join), do some manipulations and write the result into another internal table. Something that would look like following:

sort itab2 by datasource.
loop at itab1.
    read table itab2 with key datasource = itab1-datasource.
    if sy-subrc eq 0.
        itab3-datasource = itab1-datasource.
        " etc
        append itab3.

The problem is that I don't have static internal tables. I have two dynamic tables represented by symbolic links, say, <itab1> and <itab2>. That means that syntax like <itab1>-datasource is not available for these dynamic tables.

Please advise how I could do the trick joining two dynamic tables?

Thank you,


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Horst Keller
Apr 07 at 07:34 AM

The common way to work with dynamic data objects are RTTI and ASSIGN COMPONENT.

Show 6 Share
10 |10000 characters needed characters left characters exceeded

Thank you Horst,

ASSIGN COMPONENT OF STRUCTURE TO actually did the trick. I managed though to skip RTTI stuff as I had known the structure of these dynamic tables beforehand.

Best regards,



Still, you may be doing a full table scan of itab2 for every record in itab1, which doesn't seem ideal .


Yes Matthew, that's exactly full table scan of itab2 for every record in itab1. I am new to ABAP, all I need is to 'inner join' two internal tables, that's not a big deal when using SQL, however OpenSQL does not work on internal tables. Could you please hint at how to avoid full table scan and still have inner join?

Not sure the answer goes where in belongs in the thread, this UI just drives me mad sometimes ... :)


"however OpenSQL does not work on internal tables"

From 7.52 on it does

FROM @itab


Define your itab2 as a HASHED table with a unique key. (Or if you really can't use a unique key, a SORTED table).


Thank you Horst, I'll take a note on that. Unfortunately I'm developing for NW7.40 now, with no prospects to upgrade any time soon.