Redefined data items and OCCURS clauses
IBM®
COBOL for Linux® on x86
does not support redefining a data item that has an OCCURS
clause.
When you use IBM
COBOL for Linux on x86 to compile source code where a data item with the OCCURS clause is redefined, you will receive the error messages in the following
example:
$ cat tcRedefineOccurs.cbl
01 EMPLOYEE-INFO.
03 EMPLOYEE OCCURS 50 TIMES.
05 NAME PIC X(30).
05 AGE PIC 9(3).
03 NEW-EMPLOYEE REDEFINES EMPLOYEE.
04 G2 OCCURS 50.
05 FNAME PIC X(10).
05 LNAME PIC X(20).
05 AGE PIC 9(3).
$ cob2 -o tcRedefineOccurs tcRedefineOccurs.cbl
IBM COBOL for Linux 1.2.0 compile started
0LineID Message code Message text
10 IGYLN1222-S EMPLOYEE contains a OCCURS clause. Clause ignored.
Messages Total Informational Warning Error Severe Terminating
Printed: 1 1
End of compilation 1, program PGM1, highest severity: Severe.
Return code 12
According to Standard COBOL 2002, the data item
being redefined cannot contain an OCCURS
clause.
Change your COBOL source to follow Standard COBOL 2002. For example, if you change the code in the
previous example by adding a group item and renumbering, it compiles without
messages.
$ cat tcRedefineOccurs.cbl
01 EMPLOYEE-INFO.
02 G1.
03 EMPLOYEE OCCURS 50 TIMES.
05 NAME PIC X(30).
05 AGE PIC 9(3).
02 G2 REDEFINES G1.
03 EMPLOYEE OCCURS 50 TIMES.
05 FNAME PIC X(10).
05 LNAME PIC X(20).
05 AGE PIC 9(3).