ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Internal Tables → Processing Statements for Internal Tables
Internal Tables - comp1 comp2 ...
Addresses individual components of internal table rows in a range of statements for editing internal tables and in
table expressions. If not stated otherwise, the following syntax applies to the names comp1 comp2...
:
Other versions: 7.31 | 7.40 | 7.54
Syntax
... { comp_name[-sub_comp][{+off(len)}|{->attr}] } | { (name) } ...
Effect
The following alternatives are available for specifying components:
- Directly specifying the name
comp_name
of a component.
- If the data type of the components is character-like and
flat, an offset/length
+off(len)
can be appended to the name of the component (as in substring access) to access subareas of the component. Only directly specified numbers or constants can be specified foroff
andlen
.
- If the component is structured, the structure component selector
-
can be used to access thesub_comp
components of the substructure.
- If the component has a reference type, the object component selector
->
can be used to access all visible attributesattr
of the referenced object. In this case, a table component can be specified more than once.
- Specifying a parenthesized
character-like data object
name
, which contains the name of the component when the statement is executed.
- The name of the component in
name
can contain an offset/length.
- The object component selector
->
can be specified inname
to read attributes, but only those attributes can be addressed that can be identified statically.
name
is not case-sensitive. Ifname
only contains blanks, this specified component is ignored when the statement is executed. Ifname
contains a nonexistent component, a non-handleable exception is raised.
- Specifying the pseudo component
table_line
to address the whole table row as a component.
Notes
- A component can only be specified more than once if it has a reference type. Further components,
however, can be specified alongside
table_line
. This is necessary, for example, if the row type of the internal table is an object reference and the value of the reference and the value of an attribute of the object are to be specified at the same time.
- If the table has a non-structured row type, the pseudo comment
table_line
can be addressed as the only component.
- The pseudo component
table_line
is a reserved name. In ABAP and in ABAP Dictionary, no structure components calledtable_line
can be declared.
- If the row type of the internal table cannot be statically identified, the components can usually only be specified dynamically and not directly.
- The components specified must not be elementary.
- If the data type allows it (character-like and flat), an offset/length can also include adjacent components
- A customizing include must not be specified as a component if it is empty.
Example
Sorting by a dynamically specified component. An incorrect name produces a runtime error.
DATA(column) = `carrid`.
cl_demo_input=>request( CHANGING field = column ).
DATA itab TYPE TABLE OF spfli WITH EMPTY KEY.
SELECT *
FROM spfli
INTO TABLE @itab.
SORT itab BY (column).
cl_demo_output=>display( itab ).