ABAP Keyword Documentation → ABAP - Reference → Declarative statemnts → Data Types and Data Objects → Declaring Data Objects → DATA → DATA - TABLE OF → DATA - tabkeys
DATA - secondary_key
Other versions: 7.31 | 7.40 | 7.54
Syntax
... {UNIQUE HASHED}|{UNIQUE SORTED}|{NON-UNIQUE SORTED}
KEY key_name COMPONENTS comp1 comp2 ... .
Effect
Defines a secondary
table key of an internal table. The syntax and semantics of the additions are the same as those
for the TYPES
statement for standalone table types.
Programming Guideline
Use secondary keys in a way that benefits the table.
Notes
-
When internal tables are accessed with the statements
READ TABLE itab, LOOP AT
itab,
MODIFY itab
, andDELETE itab
, a secondary key can be used to determine the rows to be processed or the processing order. To do this, the additionsWITH [TABLE] KEY ... COMPONENTS
orUSING KEY
must be specified. A secondary key is never used implicitly. -
The
INSERT itab
statement determines the insert position using the primary key and primary index only. A secondary key can be specified only for the source table from which multiple rows are copied. The latter also applies to theAPPEND
statement. -
If a secondary key is defined, the addition
WITH HEADER LINE
can no longer be specified, even outside classes. -
For more information, see
TYPES
.
Example
The DEMO_SECONDARY_KEYS program demonstrates the declaration and use of a secondary table key and the resulting performance gains.