Page 1 of 1

define array whose size is equal to record count of file

PostPosted: Sun Nov 29, 2015 4:46 pm
by skb123
Hello,
Will u plz help me how to define array in cobol using occurs whose count equal to record count of file...

Thanks

Re: define array whose size is equal to record count of file

PostPosted: Sun Nov 29, 2015 6:12 pm
by NicC
Please type in english - not text.
What problem are you having?

Re: define array whose size is equal to record count of file

PostPosted: Sun Nov 29, 2015 10:44 pm
by Robert Sample
Your basic problem is that to read the file and get the record count, the program has to be executing. In order to execute, the program has to be compiled. The size of arrays in the program (except for LINKAGE SECTION and FD OCCURS DEPENDING ON arrays) is fixed at compile time. So your choices are:
- set up your code to read the file, get the record count, and change ANOTHER program's source to include that count, then submit a compile and execution of that program
- you might be able to use a subprogram to save each array element as it is read in the main program and passed to the subprogram -- whether or not this works depends upon the details of what you're doing with the array
- give up your idea as unwieldy at best and impossible at worst, explain to us what the REAL problem you are attempting to solve is, and let us suggest methods that COBOL does support and allow instead of what you want to do.