SAP ITAB KEY OPTIMIZATIONS
Get Example source ABAP code based on a different SAP table
Article
Optimized Key Operations for Tables of Types SORTED and HASHED TABLE
Accessing single records using
If you use the
If there is a partial key specification that is sufficient for the above conditions, then the system initially uses this partial key to search for an entry. In the case of
Examples
The following
SrtTab TYPE SORTED TABLE OF sflight
WITH NON-UNIQUE KEY carrid connid,
HshTab TYPE HASHED TABLE OF sflight
WITH NON-UNIQUE KEY carrid connid.
READ TABLE SrtTab INTO wa WITH KEY carrid = 'LH'.
READ TABLE SrtTab INTO wa WITH KEY carrid = 'LH'
connid = '0400'.
READ TABLE SrtTab INTO wa WITH KEY carrid = 'LH'
seatsmax = 100.
READ TABLE SrtTab INTO wa WITH KEY seatsmax = 100
carrid = 'LH'.
READ TABLE HshTab INTO wa WITH KEY carrid = 'LH'
connid = '0400'.
READ TABLE HshTab INTO wa WITH KEY carrid = 'LH'
connid = '0400'
seatsmax = 100.
CONTINUE EXAMPLE
Conversely, the following
READ TABLE SrtTab INTO wa WITH KEY seatsmax = 100.
READ TABLE HshTab INTO wa WITH KEY carrid = 'LH'.
CONTINUE EXAMPLE
Partially Sequential Quantity Access Using the
The partially sequential access of a table segment of the type
Similarly to the
Examples
The following
...
ENDLOOP.
LOOP AT SrtTab INTO wa WHERE carrid = 'LH' AND
connid = '0400'.
...
ENDLOOP.
LOOP AT SrtTab INTO wa WHERE carrid = 'LH' AND
seatsmax > 99 AND
seatsmax < 200.
...
ENDLOOP.
CONTINUE EXAMPLE
while the following
...
ENDLOOP.
LOOP AT SrtTab INTO wa WHERE carrid >= 'LH' AND
connid = '0400'.
...
ENDLOOP.
Notes As is the case with all key operations, it is always sensible for performance reasons to specify the keys in the same order as in the definition of the table key. If this is not the case, the key specifications have to be standardized against the table key, which can cause additional runtime costs (for example in the case of dynamic key specifications).
A key specification may contain neither duplicate nor overlapping partial keys. Otherwise a syntax or runtime error will occur.