CRITICAL
Rule Definition
When a the READ command is used without the BINARY SEARCH option, the internal table is sequentially searched (equivalent of an SQL table scan). The consequence is poor performance especially when the size of internal table is large or if it grows. Instead of this, it is recommended to use the BINARY SEARCH option. The binary search algorithm is much faster to search of a value in an internal table. It is however necessary to sort the internal table before doing a binary search in order to get that performance advantage.
Remediation
Add the BINARY SEARCH option to the statement and check that the internal table is sorted before using the READ statement.
Violation Code Sample
Example 1
READ TABLE int_fligh WITH KEY airln = 'AF'.
Example 2
LOOP AT itab INTO wa.
READ myStandardTable INTO wa2 WITH KEY id = 1.
ENDLOOP.
Fixed Code Sample
Remediation Example 1
READ TABLE int_fligh WITH KEY airln = 'AF' BINARY SEARCH.
Remediation Example 2
LOOP AT itab INTO wa.
READ myStandardTable INTO wa2 WITH KEY id = 1
BINARY SEARCH.
ENDLOOP.
Reference
ABAP Objects, Keller-Kruger, SAP Press
Enhancing the Quality of ABAP Development, Meijs-Krouwels-Heulmans-Sommen, SAP Press
Related Technologies
Technical Criterion
Efficiency - SQL and Data Handling Performance
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.