sapdev logo background
sapdev logo sapdev logo
Comments

SAP ITAB TABLE LINE documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

Pseudo Component TABLE_LINE for Internal Tables

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 line 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.

<(>@3U@<)> In ABAP Objects, that is, classes and class pools , a stricter syntax check is performed.
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.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




ITAB_STREAMS
ITAB_WHERE_OPTIMIZATION




comments powered by Disqus