Get Example source ABAP code based on a different SAP table
ABAP_ITAB - Primary Table Key Each internal table has a primary table key that allows access to individual lines of the table by specifying a key.
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 role.
The primary table key of a standard table > can also be empty>, that is, it does not contain any key fields.
In the case of key accesses for internal tables, the primary key is always used implicitly in processing statements> as long as no secondary key is specified. In table expressions>, the primary key must also 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 category> 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, performs 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 administration for the primary table key of standard tables.
Latest 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. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Declaration of a hashed table with a unique primary key. The table is filled with data from a database table and accessed using a table expression> with values specified for the primary key. ABEXA 01060 ABAP_EXAMPLE_END