CRITICAL
Rule Definition
The INITIALIZE generates a MOVE for every non-filler data item and can sometimes use a lot of CPU, especially for data items using the OCCURS clause.
Moreover, the INITIALIZE statement cannot assign values to items with variable-length tables (that is, a table that was defined using the OCCURS DEPENDING ON clause).
As a consequence, using this statement can impact the performance of the program and it is possible that some data items not be initialized correctly.
Remediation
Try to replace the INITIALIZE statement by specific MOVE statements or to copy an initialized variable into the group or table to initialize.
For instance, move spaces to the group and then move zeroes to numeric items.
Violation Code Sample
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A.
05 A1 PIC 9(5).
05 A2 PIC X(10).
05 B OCCURS 10.
10 B1 PIC X(10).
10 B2 PIC X(30).
05 FILLER PIC X(10)
*
PROCEDURE DIVISION.
INIT.
INITIALIZE A.
Fixed Code Sample
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A.
05 A1 PIC 9(5).
05 A2 PIC X(10).
05 B OCCURS 10.
10 B1 PIC X(10).
10 B2 PIC X(30).
05 FILLER PIC X(10)
*
PROCEDURE DIVISION.
INIT.
MOVE SPACES TO A.
MOVE ZERO TO A1.
GOBACK.
Reference
IBM Cobol - Best Practices and Recommendations
Related Technologies
Technical Criterion
Programming Practices - Unexpected Behavior
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.