Unlike sorted tables, hashed tables, and key access to internal tables, which were only introduced in Release 4.0, standard tables already existed several releases previously. Defining a line type, table type, and tables without a header line have only been possible since Release 3.0. For this reason, there are certain features of standard tables that still exist for compatibility reasons.
Before Release 3.0, internal tables all had header lines and a flat-structured line type. There were no independent table types. You could only create a table object using the OCCURS addition in the DATA statement, followed by a declaration of a flat structure:
DATA: BEGIN OF itab OCCURS n,
...
f1...,
f2...,
...
END OF
itab.
This statement declared an internal table itabwith the line type defined following the OCCURS addition. Furthermore, all internal tables had header lines.
The number n in the OCCURS addition had the same meaning as in the INITIAL SIZE addition from Release 4.0. Entering ‘0’ had the same effect as omitting the INITIAL SIZE addition. In this case, the initial size of the table is determined by the system.
The above statement is still possible in Release 4.0, and has roughly the same function as the following statements:
TYPES: BEGIN OF itab,
...
f1...,
f2...,
...
END OF itab.
DATA itab TYPE STANDARD TABLE OF itab
WITH NON-UNIQUE DEFAULT KEY
INITIAL SIZE n
WITH HEADER LINE.
In the original statement, no independent data type itabis created. Instead, the line type only exists as an attribute of the data object itab.
Since Release 3.0, it has been possible to create table types using
TYPES type TYPE|LIKE linetype OCCURS n.
and table objects using
DATA itab TYPE|LIKE linetype OCCURS n [WITH HEADER LINE].
statement. The effect of the OCCURS addition is to construct a standard table with the data type linetype. The line type can be any data type. The number n in the OCCURS addition has the same meaning as before Release 3.0. Before Release 4.0, the key of an internal table was always the default key, that is, all non-numeric fields that were not themselves internal tables.
The above statements are still possible in Release 4.0, and have the same function as the following statements:
TYPES|DATA itab TYPE|LIKE STANDARD TABLE OF
linetype
WITH NON-UNIQUE DEFAULT KEY
INITIAL SIZE n
[WITH HEADER LINE].
They can also be replaced by the following statements:
When you create a standard table, you can use the following forms of the TYPES and DATAstatements. The addition INITIAL SIZE is also possible in all of the statements. The addition WITH HEADER LINE is possible in the DATA statement.
Generic Standard Table Type:
TYPES itab TYPE|LIKE [STANDARD] TABLE OF linetype.
The table key is not defined.
Fully-Specified Standard Table Type:
TYPES itab TYPE|LIKE [STANDARD] TABLE OF
linetype
WITH [NON-UNIQUE]
key.
The key of a fully-specified standard table is always non-unique.
Short Forms of the DATA Statement
DATA itab TYPE|LIKE [STANDARD] TABLE OF linetype.
DATA itab TYPE|LIKE [STANDARD] TABLE OF
linetype
WITH
DEFAULT KEY.
Both of these DATA statements are automatically completed by the system as follows:
DATA itab TYPE|LIKE STANDARD TABLE OF linetype
WITH
NON-UNIQUE DEFAULT KEY.
The purpose of the shortened forms of the DATAstatement is to keep the declaration of standard tables, which are compatible with internal tables from previous releases, as simple as possible. When you declare a standard table with reference to the above type, the system automatically adopts the default key as the table key.
Fully-Specified Standard Tables:
DATA itab TYPE|LIKE [STANDARD] TABLE OF
linetype
WITH [NON-UNIQUE] key.
The key of a standard table is always non-unique.