Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing sequentially from an indexed file 1

Status
Not open for further replies.

Preka

Programmer
May 11, 2004
55
Quite basically, how do I do it?

The book I have says that, to read an indexed file, I have to first move a value into the key field to do it. Ok, fine, got it.

But I have an indexed file with about 35 records on it and I want to write the whole thing sequentially to another file. Typing each of the keys in manually is obviously impractical. I figure there has to be a fairly simple way to do it, but I don't know how.

Thanks for any help,
Cobol-newb.
 
At least in environments I've used, you don't even have to START the file. Simply specify ACCESS SEQUENTIAL in the SELECT. OPEN the file INPUT. READ the file. It will be retrieved in primary key order.

Glenn
 
Actually, the access mode shouldn't really matter. As soon as you open an indexed file (whether in sequentail or dynamic mode), the file pointer is set to the first record, and the current key is set to the primary key.

Do something like this ...

Code:
open input in-file
open output out-file

read in-file next
perform until in-file-eof
  write out-record from in-record
  read in-file next
end-perform

close in-file out-file
 
Use the key and move low values to it and and then use that to start the file using dynamic access on the file. After that use a loop that just uses READ NEXT RECORD.

If you do not like my post feel free to point out your opinion or my errors.
 
just use the access mode sequential.
open input file-name.
read file-name at end etc;
I use this all the time in Rm_Cobol

Enjoy Bob
 
I often use Dynamic because I am updating redords also.

If you do not like my post feel free to point out your opinion or my errors.
 
Or specify ACCESS MODE DYNAMIC, OPEN file-name I-O, and READ file-name NEXT RECORD.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top