I have a requirement which states something like this:
KSDS of employee records and the hourly wage formed the record key. Also the program is interested in those employees earning $7 and $9 per hour and those earning $15 per hour and above.
In Input Output Section of Environment division I will declare it as:
SELECT file-name ASSIGN TO ddname
ORGANIZATION IS Indexed
ACCESS MODE IS Sequential
RECORD KEY IS key1
In the working storage section I define the key as the hourly wage.
Now while reading it sequentially it is fine. But if I have to read the file randomly how will I be able to do so as ACCESS MODE IS Sequential.
whereas if I declare it as ACCESS MODE IS Random how to read it sequentially. What I am trying to say is that if I have to read same file both sequentially and randomly how do I need to define in I-O section. Do i need to define twice this file in Environment division? This requirement is because my logic need to access the same file sequentially and randomly. Can someone give the snippet of the code.
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
Hi Mr Banerjee...
Am just leaving my office now.. So cant help you with the any sample code..
Anyway... you could have a look into the DYNAMIC access mode available... If my understanding of your requirement is correct, you could use the DYNAMIC option with a couple to condition checks and get the required o/p.
There is a link at the top of the page to the manuals. Click on it, find the COBOL Language Reference manual, and read up on ACCESS MODE IS DYNAMIC. You can also read about the different forms of the READ statement, and the START statement.