In internal tables, you can generally address the entire table row in a key specification by using the
pseudo component TABLE_LINE. This is particularly useful
for tables whose row type does not have a structure.
You can, for example, define a sorted table
of integers as follows and process it in a loop with a WHERE condition:
DATA: wa TYPE i,
itab TYPE SORTED TABLE OF i WITH
UNIQUE KEY TABLE_LINE.
...
LOOP AT itab INTO wa WHERE KEY table_line > 5.
...
ENDLOOP.
As TABLE_LINE is similar to a row component, the underlying row structure should not contain a component of the same name.
The old form TABLE LINE (without the underscore) is obsolete.
SAP was unable to provide continued support since this form does not allow you to use references in tables to access attributes of the object referenced.
ABAP Objects, that is, classes and class pools, performs a stricter syntax check. See Cannot use Obsolete Key Declaration with TABLE LINE.
In the following example, ITAB is a table of object references.
The associated class has an attribute NAME. You can access
this attribute by specifying TABLE_LINE->NAME in a LOOP statement.
CLASS my_class DEFINITION.
PUBLIC SECTION.
DATA: name TYPE string.
...
ENDCLASS.
DATA: wa TYPE REF TO my_class,
itab
TYPE TABLE OF REF TO my_class.
CREATE OBJECT wa. wa->name = 'Hugo'. INSERT wa INTO
TABLE itab.
CREATE OBJECT wa. wa->name = 'Nora'. INSERT wa INTO TABLE itab.
CREATE OBJECT wa. wa->name
= 'Jimmy'. INSERT wa INTO TABLE itab.
CREATE OBJECT wa. wa->name = 'Nora'. INSERT wa INTO TABLE itab.
LOOP AT itab INTO wa WHERE table_line->name = 'Nora'.
...
ENDLOOP.