Get Example source ABAP code based on a different SAP table
ARTICLE
Primary Table Key Each internal table has a primary table key that enables access to individual rows in the table by means of a key specification.
The components of the primary table key are declared using the UNIQUE|NON-UNIQUE KEY additions of the statements TYPES, DATA, and so on.
The standard key, which can be declared both explicitly and implicitly, has a special part to play here.
The primary table key of a standard table can also be empty, meaning that it does not contain any key fields.
In the case of key accesses for internal tables, the primary key is always used implicitly processing statements as long as no secondary key is specified. In table expressions, the primary key must also always be specified explicitly.
The primary key has the predefined name primary_key, with which it can also be addressed explicitly in processing statements. In table expressions, primary_key or an alias name must be specified, if the primary key is to be used explicitly.
Access to an internal table using the primary table key is determined by the table type and not the table key. For sorted tables and hashed tables, key access is always optimized using the primary table key. Primary key access to standard tables, however, uses a linear search.
The key fields of the primary table key of sorted tables and hashed tables are always read-only.
In the case of sorted tables and hashed tables, separate key administration exists for the primary table key, which enables optimized access but also affects the memory requirement of the internal table. There is no separate key administration for the primary table key of standard tables.
Notes
Since sorted tables and hashed tables have real key administration for the primary key, unlike standard tables, these tables are also grouped under the term key tables.
To achieve optimized key access to standard tables, secondary keys can be used.