Sequential read on a sorted table
sequential_read_sorted
Pseudo comment: EC CI_SORTSEQ
Description
A WHERE condition or a free key on a sorted table that does not use the primary key
Extended Information
A sorted table is read with a binary search only when the condition fixes an initial part of
its key. When the first key component is not compared with = or EQ (or IS INITIAL) in a part of the condition joined
by AND, every line is read, like on a standard table. The SAP check "Low Performance Operations on Internal Tables"
reports this as "Possible sequential read on a sorted table".
Checked: LOOP AT ... WHERE, DELETE ... WHERE, MODIFY ... WHERE, READ TABLE ... WITH KEY and table expressions
itab[ comp = ... ], on a table whose type is statically known as SORTED with explicit key components, using the
primary key.
Not checked: standard, hashed, generic and unknown table types, tables with a default key, a dynamic WHERE or
dynamic components, WITH TABLE KEY, a named key (USING KEY, KEY ... COMPONENTS) other than primary_key,
READ TABLE ... BINARY SEARCH and access by index, including LOOP AT and DELETE with FROM or TO.
Fix: compare the first key component with =, change the key or the table type, or add a secondary key.
If the sequential read is intended, add the pseudo comment "#EC CI_SORTSEQ to the statement.