I am new to COBOL(and OpenCOBOL) and my question is about "complex-odo" (OCCURS...DEPENDING ON) in OpenCOBOL.
I used 1.0 on following code
......
01 W-PTDO-PROC-TBL.
05 W-PTDO-PROC-ENTRY OCCURS 0 TO 450 TIMES
DEPENDING ON W-PTDO-PROC-MAX
INDEXED BY W-PTDO-PROC-INDX.
10 W-PTDO-PROC-APC PIC X(05).
10 W-PTDO-PROC-LNSUB PIC S9(07) COMP-3.
10 W-PTDO-PROC-KEY.
15 W-PTDO-PROC-WA-OFFSET PIC 9(08)V99.
15 W-PTDO-PROC-UNITS PIC 9(09).
10 W-PTDO-PROC-DEVICE-CNT PIC 9(03).
10 W-PTDO-PROC-DARRAY OCCURS 0 TO 450 TIMES
DEPENDING ON W-PTDO-DARRAY-MAX
INDEXED BY W-PTDO-DARRAY-INDX.
15 W-PTDO-PROC-DHCPCS PIC X(05).
10 W-PTDO-DARRAY-SIZE PIC 9(03).
10 W-PTDO-PROC-TOT-DCHRGS PIC 9(10)V99.
10 W-PTDO-PROC-TOT-DUNITS PIC 9(05).
10 W-PTDO-PROC-USED PIC X(01).
......
and cobc returns with this error msg:
Error: 'W-PTDO-PROC-ENTRY' cannot have the OCCURS clause due to 'W-PTDO-PROC-DARRAY'
And above error msg is issued from field.c where I found this comment /* the data item that contains a OCCURS DEPENDING clause shall not be subordinate to a data item that has the OCCURS clause */
Is there anyway to make OpenCOBOL support this "complex-odo"?
My above code snippet, with "OCCURS DEPENDING" nested under a higher level "OCCURS" clause, seems to be a well-defined "complex-odo" according to appendix of IBM's COBOL Programming Guide.
Thank you,
Billy Rong
You cannot have a variable length array (OCCURS DEPENDING ON) inside another array!
The processing required is just too complex. If the length of the inner array item was allowed to vary, the only possible way to calculate the start of the Nth entry of the outer array is to sequentially access each inner member from 1 to N and use the DEPENDING ON count to work out its length, and, hence the start of the next array entry.