SAP READ ITAB USING KEY ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Key Accesses
This example measures the runtime of the statement READ TABLE with various table keys.

ABAP_SOURCE_CODE
DEMO CL_DEMO_READ_TABLE_USING_KEY

ABAP_DESCRIPTION
The table itab is a standard table with a non-unique primary key, a unique secondary sorted key, and a unique secondary hash key. For demonstration purposes, this class hides the syntax warning that different table keys in an internal table cannot contain the same components using the pragma ##TABKEY.
The class measures the average access time of the statement READ TABLE to individual table lines, depending on the number of lines in the table. The lines are accessed using the different keys. The keys are specified statically in the method measure_static and dynamically in the method measure_dynamic.
The result demonstrates that the response times for static access are as expected from around 50 to 100 table lines:
When a standard table is accessed using the primary key, the average access time increases linearly with the number of table lines.
When a standard table is accessed using a secondary sorted key, the average access time increases logarithmically with the number of table lines.
When a standard table is accessed using a secondary hash key, the access time is constant.
In dynamic accesses, each access incurs the additional time required to evaluate the dynamically specified key.