CRITICAL
Rule Definition
Using indexes to address a table is more efficient than using subscripts since the index already
contains the displacement from the start of the table and does not have to be calculated at run-time. Subscripts,
on the other hand, contain an occurrence number that must be converted to a displacement value at run-time before
it can be used.
Remediation
Prefer to use index rather than subscript. Add an INDEXED clause in table definition and use this index.
Violation Code Sample
01 DIRECT-TAX-RATE.
02 TAX-RATE PIC 99 OCCURS 5 TIMES.
01 TX-IND PIC S9(8) COMP.
...
MOVE 4 TO TX-IND.
MOVE TAX-RATE(TX-IND) TO SEC-RATE.
...
Fixed Code Sample
01 DIRECT-TAX-RATE.
02 TAX-RATE PIC 99 OCCURS 5 TIMES INDEXED BY TX-INDEX.
...
SET TX-INDEX TO 4.
MOVE TAX-RATE(TX-INDEX) TO SEC-RATE.
Reference
IBM Cobol - Best Practices and Recommendations
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.