Can you provide one or more COBOL coding techniques or recommendations, based on your experience, where efficiencies can be gained?
Yes, the biggest one would be to avoid using subscripts -- use indexes instead. By the way, all of my performance tips are available in the SHARE presentation called LE Performance Tips and Techniques.
COBOL coding tips -- table element references
Given these data descriptions:
77 SUB1 PIC S9(4) USAGE BINARY. 01 GRP1. 05 TAB1 OCCURS 1000 INDEXED BY TABINDX. 10 SALES PIC 9(7) PACKED-DECIMAL. 10 EXPENSES PIC 9(7) PACKED-DECIMAL. 10 INVENTORY PIC 9(7) PACKED-DECIMAL.
PERFORM VARYING SUB1 FROM 1 BY 1 UNTIL SUB1 > 1000 COMPUTE SALES-TOTAL = SALES-TOTAL + SALES(SUB1) COMPUTE EXPENSE-TOTAL = EXPENSE-TOTAL + EXPENSES(SUB1) COMPUTE INVENTORY-TOTAL = INVENTORY-TOTAL + INVENTORY(SUB1) END-PERFORM
PERFORM VARYING TABINDX FROM 1 BY 1 UNTIL TABINDX > 1000 COMPUTE SALES-TOTAL = SALES-TOTAL + SALES(TABINDX) COMPUTE EXPENSE-TOTAL = EXPENSE-TOTAL + EXPENSES(TABINDX) COMPUTE INVENTORY-TOTAL = INVENTORY-TOTAL + INVENTORY(TABINDX) END-PERFORM
Dig deeper on Mainframe operating systems and management
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.