define array whose size is equal to record count of file



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

define array whose size is equal to record count of file

Postby skb123 » Sun Nov 29, 2015 4:46 pm

Hello,
Will u plz help me how to define array in cobol using occurs whose count equal to record count of file...

Thanks
skb123
 
Posts: 2
Joined: Sun Nov 29, 2015 3:23 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Sun Nov 29, 2015 6:12 pm

Please type in english - not text.
What problem are you having?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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

Postby Robert Sample » Sun Nov 29, 2015 10:44 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post