Ansicht
Dokumentation

ABAPDATA_SECONDARY_KEY - DATA SECONDARY KEY

ABAPDATA_SECONDARY_KEY - DATA SECONDARY KEY

Fill RESBD Structure from EBP Component Structure   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.
SAP E-Book

DATA, secondary_key

Short Reference


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

Effect

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.

Use secondary keys in a way that benefits the table.

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.
  • If a secondary key is defined, the obsolete addition WITH HEADER LINE can no longer be specified, even outside classes.
  • For more information, see TYPES.

Example

Declaration of an internal table with one primary key and two secondary keys.

Example

As in the previous example but with explicit naming of the primary key.

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






ABAP Short Reference   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 4122 Date: 20240425 Time: 084602     sap01-206 ( 67 ms )