SAP KEYNAME



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - keyname
The name of the table key can be specified in a range of statements and in table expressions for the processing of internal tables. The table key name can used to access a table line or to control processing. The following syntax applies to keyname:

ABAP_SYNTAX
... key_name $| (name) ...

What does it do?
The name of a table key can either be specified directly, as key_name, or dynamically, as the content of a parenthesized character-like data object name. This is not case-sensitive. If the name is specified directly, it must be known statically that the internal table has this key. With generic data types, the name can only be specified dynamically. If the name is specified dynamically and is incorrect, this raises an uncatchable exception.
The following can be specified:
a secondary table key using its name
the primary table key using its predefined name primary_key
the primary table key using an alias
the table key used in a LOOP-loop using its predefined name loop_key. In this case, the statement must be executed within the loop.



Latest notes:

Normally secondary table keys are specified. Only if searches are to be performed explicitly in a table expression using the primary table key does the key need be specified using its predefined name primary_key or an alias name.
When specifying the primary table key using primary_key, it is important to note that it can also be empty for standard tables. This can produce unexpected behavior in statements where the key is used to specify the lines to be processed.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Dynamic specification of the key according to which the LOOP loop is executed. The loop can be executed with the entries skey and primary_key. This is not case sensitive. Any other entries produce a runtime error.
ABEXA 01068
ABAP_EXAMPLE_END