SAP NetWeaver AS ABAP Release 751, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Processing Internal Data → Internal Tables → Internal Tables - Overview → Table Keys → Primary Table Key →Empty Table Key
The primary table key of a standard table can be empty. An empty table key does not contain any key fields.
Note
Sorted keys and hash keys are never empty, regardless of whether they are primary or secondary.
Declaration
An empty primary table key can be created as follows:
Notes on Use
Uncritical use
An empty primary table key can be used to handle a table like an array. This means that filling the table and other access do not rely on an order determined by key values. In this case, an empty internal table key can be used in all statements that determine (implicitly or explicitly) the order in which the internal table is accessed.
Notes
Example
A particularly prominent example is the statement LOOP AT itab, which when used implicitly or explicitly (using USING primary_key) defines the processing order with respect to the primary table index, but is otherwise ignored.
Critical use
In the following statements, which work with the primary table key without specifying the key fields explicitly, specifying an empty primary table key is critical and generally produces unexpected behavior. An empty table key that is known statically produces a syntax check warning.
Note
The statements described above can be particularly unpredictable when using the standard key (which itself can be declared implicitly) to declare an empty internal table key.
Example
Example
Typical use of a table with an empty table key, in which the order of the rows should not be changed by sorting. A SORT source statement would have no effect.
DATA source
TYPE STANDARD TABLE OF string
WITH EMPTY KEY.
READ REPORT 'DEMO_TAB_EXP_LINE' INTO source.
cl_demo_output=>display( source ).