KEYDEF - Defining a Key for Internal Tables

Alternatives:

1. KEY key1 ... keyn

2. KEY TABLE_LINE

3. DEFAULT KEY

Effect

You can use any table fields as the key for an internal table, as long as they are not tables and do not contain tables themselves. You use UNIQUE and NON-UNIQUE to specify whether the table key is unique or not. If you are using the HASHED TABLE access type, the key must always be unique. If you are using the STANDARD TABLE access type, you can only use NON-UNIQUE. In this case, you can leave out the clause altogether. Otherwise, key specifications without uniqueness are generic so you cannot use specified types with DATA to type fields.

Alternative 1

KEY key1 ... keyn


Effect

The keys key1 ... keyn are table fields in the associated table. The sequence in which you specify the key is significant.

Alternative 2

KEY TABLE_LINE


Effect

The line type of the table is the key. This is particularly appropriate in tables without a structure. The TABLE_LINE name is a pseudo-component that allows you to specify an explicit key for a table without a structured line type.

Note

The TABLE LINE addition is obsolete. For further details, refer to Pseudo-component TABLE_LINE in Internal Tables.

Alternative 3

DEFAULT KEY


Effect

The key fields are the standard keys. Note that you can only specify an empty key for tables with access type STANDARD TABLE.

Note

Performance:

In general, the runtime required to access an internal table by its key increases with the length of the table key. The access time improves if the key is as compact as possible (no gaps) and left-justified.

Additional help

Internal Table Types