ABAP Alternative 1 ... $[UNIQUE$|NON-UNIQUE$] ${KEY ...$}$|${DEFAULT KEY$}>
What does it do? Definition of the primary table key of an internal table by specifying components or defines it as a standard key. The syntax and semantics of the additions are the same as for the statement TYPES>> for standalone table types, except that the primary key of a bound > table type must always be fully specified.
In standard tables>, only the addition NON-UNIQUE KEY> can be specified. If uniqueness is not specified, this addition is added implicitly. The addition UNIQUE KEY> cannot be specified.
In sorted tables>, one of the additions UNIQUE KEY> or NON-UNIQUE KEY> must be specified.
In hashed tables>, the addition UNIQUE KEY> must be specified. If no primary key is specified for DATA> using WITH>, the addition WITH NON-UNIQUE DEFAULT KEY> is added implicitly for standard tables. This gives the table a standard key>, which can be empty. In sorted tables and hashed tables, the primary key must be specified explicitly and cannot be empty. BEGIN_SECTION VERSION 5 OUT If the name of the primary key primary_key> is specified explicitly, the obsolete addition WITH HEADER LINE>> can no longer be specified, even outside the classes. END_SECTION VERSION 5 OUT
Latest notes: The declaration of the primary table key as a standard key> can be critical for various reasons. It is best to specify key fields explicitly instead. In particular, it must be ensured that the declaration of the standard key is not added by mistake because the key was not specified explicitly. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Definition of a sorted table with a primary key without an explicit name specification. ABEXA 00178 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 Definition of a sorted table with a primary key and an explicit name specification. ABEXA 00179 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 Definition of a sorted table with a primary key for which an alias name is defined. ABEXA 00180 ABAP_EXAMPLE_END • EMPTY KEY DATA • EMPTY KEY CLASS-DATA • EMPTY KEY CONSTANTS • EMPTY KEY STATICS
ABAP Alternative 2 ... EMPTY KEY>
What does it do? Definition of an empty primary key> for an internal table. This variant is possible for standard tables only. The syntax and semantics are the same as for the statement TYPES>>.
Latest notes:
The addition EMPTY KEY> can provide clarity in all situations in which the definition of a table key is not important.
In general, it is recommended that the addition EMPTY KEY> is used instead of not specifying a key definition, since otherwise the standard key> is used, which often produces unexpected results. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Declaration of a table with an empty primary key. Using the SORT>> statement without specifying a sort criterion would have no effect for this table. ABEXA 00181 ABAP_EXAMPLE_END