I'd like to comment about the chaining of Table Expressions.
So the answer corresponding to the OP example is that a single Table Expression must be used (itab[...]
) with as many components as needed, and not a chain of table expressions as was done (itab[...][...]
).
lt[ carrid = 'LH' ][ connid = '2407' ]
can never be valid (because connid = '2407'
would imply that each line of LT
is itself an internal table but carrid = 'LH'
is contradictory as it means that each line of LT
is a structure).
But other syntaxes of chained table expressions can be valid, like e.g. (provided that the internal tables are defined adequately)
itab[ 1 ][ comp1 = 'A' ]
itab[ comp1 = 'A' ][ 1 ]
itab[ comp1 = 'A' ]-itabx[ compx = 42 ]
Here is an example that you can play with:
TYPES: BEGIN OF ty_structure,
connid TYPE c LENGTH 4,
END OF ty_structure,
ty_table TYPE STANDARD TABLE OF ty_structure WITH EMPTY KEY,
BEGIN OF ty_structure_2,
carrid TYPE c LENGTH 2,
table TYPE ty_table,
END OF ty_structure_2,
ty_table_2 TYPE STANDARD TABLE OF ty_structure_2 WITH EMPTY KEY,
ty_table_3 TYPE STANDARD TABLE OF ty_table_2 WITH EMPTY KEY.
DATA(lt) = VALUE ty_table_3( ( VALUE #( ( carrid = 'LH' table = VALUE #( ( connid = '2407' ) ) ) ) ) ).
DATA(structure) = lt[ 1 ][ carrid = 'LH' ]-table[ connid = '2407' ].