67 lines
1.7 KiB
Plaintext
67 lines
1.7 KiB
Plaintext
The binary algorithm used by ``++SEARCH ALL++`` is far more efficient for large tables than the one used by ``++SEARCH++``. While it's not always possible to use ``++SEARCH ALL++``, it should be the preferred algorithm.
|
|
|
|
|
|
This rule raises an issue when tables with more than the specified number of possible entries are searched using ``++SEARCH++``.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
Using the default threshold of 500:
|
|
|
|
----
|
|
01 MY-TABLE.
|
|
05 MY-TAB-ELEM OCCURS 300000
|
|
INDEXED BY MY-TAB-IND.
|
|
10 MY-ATTR1 PIC X(07).
|
|
10 MY-ATTR2 PIC X(07).
|
|
10 MY-ATTR3 PIC X(07).
|
|
|
|
01 MY-TAB2.
|
|
05 MY-TAB2-ELEM OCCURS 300000
|
|
ASCENDING MY-ATTR1 *> Key is defined. Why not use it?
|
|
INDEXED BY MY-TAB-IND.
|
|
10 MY-ATTR1 PIC X(07).
|
|
10 MY-ATTR2 PIC X(07).
|
|
10 MY-ATTR3 PIC X(07).
|
|
|
|
01 MY-TAB-IND PIC 9(08).
|
|
|
|
|
|
SEARCH MY-TAB-ELEM. *> Noncompliant; define a key & use binary search
|
|
AT END...
|
|
|
|
SEARCH MY-TAB2-ELEM. *> Noncompliant
|
|
AT END...
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
01 MY-TABLE.
|
|
05 MY-TAB-ELEM OCCURS 300000
|
|
ASCENDING MY-ATTR1
|
|
INDEXED BY MY-TAB-IND.
|
|
10 MY-ATTR1 PIC X(07).
|
|
10 MY-ATTR2 PIC X(07).
|
|
10 MY-ATTR3 PIC X(07).
|
|
|
|
01 MY-TAB2.
|
|
05 MY-TAB2-ELEM OCCURS 300000
|
|
ASCENDING MY-ATTR1
|
|
INDEXED BY MY-TAB-IND.
|
|
10 MY-ATTR1 PIC X(07).
|
|
10 MY-ATTR2 PIC X(07).
|
|
10 MY-ATTR3 PIC X(07).
|
|
|
|
01 MY-TAB-IND PIC 9(08).
|
|
|
|
|
|
SEARCH ALL MY-TAB-ELEM.
|
|
AT END...
|
|
|
|
SEARCH ALL MY-TAB2-ELEM.
|
|
AT END...
|
|
----
|
|
|