ABAP Keyword Documentation → ABAP − Reference → Declarations → Declaration Statements → Data Types and Data Objects → Declaring Data Objects → DATA
DATA - TABLE OF
Other versions: 7.31 | 7.40 | 7.54
Syntax
DATA itab { {TYPE [STANDARD]|SORTED|HASHED TABLE OF [REF TO] type}
| {LIKE [STANDARD]|SORTED|HASHED TABLE OF dobj} }
[tabkeys]
[INITIAL SIZE n]
[VALUE IS INITIAL]
[READ-ONLY].
Effect
This statement defines an internal table. The definition of the row type, the table category
(STANDARD TABLE
,
SORTED TABLE
, or HASHED
TABLE), and the initial memory size INITIAL
SIZE matches the definition of table categories in the section
TYPES
- TABLE OF
exactly. Using DATA
,
these additions create a bound table type. The generic types ANY TABLE
and INDEX TABLE
cannot be used with DATA
.
tabkeys
is used to define the
table keys of the internal table, which, unlike data types, cannot be generic.
Notes
- When an internal table is created as a data object, only the administration entry for an internal table is generated. The actual table rows are not inserted until runtime.
-
When an internal table is defined, the start value after the addition
VALUE
must beIS INITIAL
. -
Several obsolete variants for declaring standard tables exist and are described under
Obsolete Declarations. In particular, note
the obsolete use of the additions WITH
HEADER LINE and
OCCURS
.
Example
Declares an internal hashed table. The row type corresponds to the structure of the database table SPFLI. Two key fields are defined for the primary table key. The other statements demonstrate how the table is filled with rows from database table SPFLI and how a row is read.
DATA: spfli_tab TYPE HASHED TABLE OF spfli
WITH UNIQUE KEY carrid connid,
spfli_wa LIKE LINE OF spfli_tab.
SELECT *
FROM spfli
WHERE carrid = 'LH'
INTO TABLE @spfli_tab.
spfli_wa = spfli_tab[ KEY primary_key
carrid = 'LH' connid = '0400' ].
...