SAP DATA SECONDARY KEY ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• KEY DATA
• UNIQUE HASHED KEY DATA
• UNIQUE SORTED KEY DATA
• NON-UNIQUE SORTED KEY DATA
• ALIAS DATA, secondary_key
• COMPONENTS DATA

DATA, secondary_key
Short Reference


ABAP_SYNTAX
... ${UNIQUE HASHED$}$|${UNIQUE SORTED$}$|${NON-UNIQUE SORTED$}
KEY key_name $[ALIAS alias_name$] COMPONENTS comp1 comp2 ...

What does it do?
Definition of a secondary table key of an internal table. The syntax and semantics of the additions are the same as those for the statement TYPES for standalone table types.

ABAP_PGL
Use secondary keys in a way that benefits the table.
ABAP_PGL_END



Latest notes:

When internal tables are accessed using the statements READ TABLE itab, LOOP AT itab, MODIFY itab, and DELETE itab or using table expressions and in mesh types and mesh paths , a secondary key can be used to specify the lines to be processed or the processing order. To do this, the additions WITH $[TABLE$] KEY ... COMPONENTS or USING KEY must be specified in the statements and the addition KEY must be used in table expressions. A secondary key is never used implicitly.
The statement INSERT itab 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 lines are inherited. The latter also applies to the statement APPEND.
If different table keys of an internal table contain the same components, a syntax check warning occurs, which can be hidden using a pragma. In the case of a reference to a non-generic table type defined using TYPES, any pragma specified there is also applied to the DATA statement. In the case of a reference to a generic table type for which no primary table key is defined, the specified pragma is not applied to the DATA statement, since this statement uses a completed table type implicitly and the pragma must also be specified for DATA.
For more information, see TYPES.
NON_V5_HINTS
If a secondary key is defined, the obsolete addition WITH HEADER LINE can no longer be specified, even outside classes.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Declaration of an internal table with one primary key and two secondary keys.
ABEXA 00185
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
As in the previous example but with explicit naming of the primary key.
ABEXA 00186
ABAP_EXAMPLE_END

VX_EXA_ONLY

ABAP_EXAMPLE_VX
The program DEMO_SECONDARY_KEYS demonstrates the declaration and use of a secondary table key and the resulting performance gains.
ABAP_EXAMPLE_END

Return to menu