Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
If you can inform the COBOL program of the number of records on the file, then you can define the ARRAY to LINKAGE and then use LE Callable Service routine 'CEEGTST' to obtain the correct amount of storage needed for the ARRAY.
You can define the ARRAY as a true ODO (Occurs Depending On) with the DEPENDING ON being a Binary-Fullword defined just above the actual ARRAY definition, within the "01" definition.
03 LS-ARRAY-NBR-RECS PIC S9(09) BINARY.
03 LS-ARRAY OCCURS 1 TO 99999 TIMES
DEPENDING ON LS-ARRAY-NBR-RECS
INDEXED BY X-LS-AR, X-LS-AR-MAX
So, for example, if the number of file-records was 100, the amount of dynamic-storage needed would be (Record-Length * Number-of-Records) + LENGTH OF LS-ARRAY-NBR-RECS.