Show TOC

 Secondary Keys for Table TypesLocate this document in the navigation structure

Use

Secondary table keys can be defined for table types in the ABAP Dictionary as well as for internal tables.

Possible secondary table keys are hash key and sorted key. Secondary keys can be divided into three categories depending on their uniqueness and the way they are accessed:

  • Unique secondary hash keys defined with Unique Hashed that are linked to table rows using a hash algorithm.
  • Unique secondary sorted keys defined with Unique Sorted that are linked to table rows using a secondary table index (in which the system sorts the key fields in ascending order).
  • Non-unique secondary sorted keys defined using Non-Unique Sorted that are linked to table rows using a secondary table index (in which the system sorts the key fields in ascending order).
    Caution

    An internal table can have up to 15 secondary table keys with different names.

    Caution

    We recommend secondary keys for internal tables that are filled once and rarely changed during program execution.

Features

Each secondary key has a unique name that must meet the naming conventions. This name cannot be either of the predefined names PRIMARY_KEY or LOOP_KEY.

Caution

The names of secondary keys and a possible alias name of the primary key must be unique.

Extras

You have the following possibilities for the definition of secondary keys:

  • Addition WITH FURTHER SECONDARY KEYS:

    This addition makes a table (independent of its primary key) generic in terms of its secondary keys.

  • Addition WITHOUT FURTHER SECONDARY KEYS

    This addition identifies the internal table declared as not generic in terms of its secondary keys.

  • No addition is specified (not specified),

    The table is generic in terms of its secondary keys only if it is also generic in terms of its primary key.

    Note

    If a table is already generic in terms of its primary key, the WITH FURTHER SECONDARY KEYS addition is superfluous but can be specified.

    If a table is not generic in terms of its primary key, the WITHOUT FURTHER SECONDARY KEYS addition is superfluous but can be specified.

This definition can also be specified in the ABAP Dictionary. To do this, perform the following:

  1. Go to the Secondary Key tab page.
  2. Select the appropriate radio button from the Further Secondary Keys radio button group.
    Caution

    If you have already defined 15 secondary keys, you cannot declare the WITH FURTHER SECONDARY KEYS addition.

See also:

Creating Table Types

Table Types