Prefer using indexes instead of subscripts | CAST Appmarq

Prefer using indexes instead of subscripts

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

Health Factor

  Efficiency


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.

Benchmark Statistics

Global Compliance

45.40%

Total Violations
16,881
Total Opportunities
30,916
Average Violations / App.
2,411.57
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Insurance

44.04%

Select from drop-down

46.65%

Financial Services

45.75%