Ansicht
Dokumentation

ABAPTYPES_KEYDEF - TYPES KEYDEF

ABAPTYPES_KEYDEF - TYPES KEYDEF

CL_GUI_FRONTEND_SERVICES - Frontend Services   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

TYPES, tabkeys

Short Reference


... $[ WITH key $]
    $[ WITH secondary_key1 $] $[ WITH secondary_key2 $] ...
    $[ ${WITH$|WITHOUT$} FURTHER SECONDARY KEYS $] ...

Additions

1. ... WITH FURTHER SECONDARY KEYS

2. ... WITHOUT FURTHER SECONDARY KEYS

Effect

Definition of the table key of a table type. The following can be defined:

The order in which the components of a table key are defined is significant for the table type. The additions WITH$|WITHOUT FURTHER SECONDARY KEYS determine the genericness with respect to the secondary table key.

An internal table type that has no table key or an incomplete table key is generic with respect to the table key. Such a table type can only be used for typing formal parameters or field symbols. A standard table type with a generic primary table key only can be specified for DATA after TYPE. This creates a bound table type with a standard key.

Primary Key

The genericity of a table type with respect to the primary key is determined as follows:

  • If WITH key is not specified, a table type is fully generic with respect to the primary key.
  • If there is no declaration about the uniqueness of the key in key, a table type is partly generic with respect to the key.
  • If a key declaration with a uniqueness declaration is made in key, a table type is not generic with respect to the primary key.

The non-generic table categories can be split up as follows:

  • If no primary key is declared for standard tables, this primary key is generic with respect to the key fields and defined implicitly as non-unique.
  • If no primary key is declared for sorted tables, this primary key is generic with respect to the key fields and uniqueness.
  • If no primary key is declared for hashed tables, this primary key is generic with respect to the key fields and uniqueness. However, it is important to note that concrete hashed tables can have only one unique key.

Secondary Key

The genericity of a table type with respect to the secondary keys depends on that of the primary key by default and can be overridden using the additions WITH$|WITHOUT FURTHER SECONDARY KEYS.

  • If the primary key is completely or partially generic, the table type is by default generic with respect to the secondary keys. The default behavior can be expressed using the addition WITH FURTHER SECONDARY KEYS. However, if the addition WITHOUT FURTHER SECONDARY KEYS is specified, the table type is generic with respect to the primary key but not with respect to the secondary key.
  • If the primary key is not generic, then the table type is by default not generic with respect to the secondary key either. The default behavior can be expressed using the addition WITHOUT FURTHER SECONDARY KEYS. However, if the addition WITH FURTHER SECONDARY KEYS is specified, the table type is generic with respect to the secondary key but not with respect to the primary key.

Note

A generic table type must not be used as a component of a structured type.

Example

Definition of a table type for a hashed table with a unique primary key as well as two non-unique secondary sorted keys, cityfrom_to and airp_from_to.

Addition 1

... WITH FURTHER SECONDARY KEYS

Effect

This addition explicitly specifies that the table type is generic with respect to the secondary key. This means that it includes table types that can have further secondary keys in addition to the optional secondary keys specified using WITH secondary_key ....

If 15 secondary keys are already defined, the addition WITH FURTHER SECONDARY KEYS cannot be specified.

Notes

  • This addition expresses the default behavior in table types with a generic primary key.
  • In table types with a non-generic primary key, WITH FURTHER SECONDARY KEYS can be used to override the default behavior and make it generic with respect to the secondary keys.

Addition 2

... WITHOUT FURTHER SECONDARY KEYS

Effect

This addition explicitly specifies that the table type is not generic with respect to the secondary key. This means that it includes only table types that have exactly those secondary keys specified using WITH secondary_key ....

Note

This addition expresses the default behavior in table types with a generic primary key.

Example

The addition WITH FURTHER SECONDARY KEYS in the declaration of the tabular type itab enables the passing of internal tables with any secondary keys to the parameter p of the method meth. Without this addition, the addition WITHOUT FURTHER SECONDARY KEYS would be used implicitly and the method call shown would not be possible.






General Material Data   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 7728 Date: 20240501 Time: 235113     sap01-206 ( 105 ms )