Skip to Main Content
PROGRAMMING IN COBOL/400: 2nd Edition
book

PROGRAMMING IN COBOL/400: 2nd Edition

by James Cooper, Nancy Stern, Robert A. Stern
January 2002
Intermediate to advanced content levelIntermediate to advanced
736 pages
18h 57m
English
Wiley
Content preview from PROGRAMMING IN COBOL/400: 2nd Edition

Chapter 13. RANDOM FILE ACCESS FOR KEYED FILES

CHAPTER OBJECTIVES

Upon completion of this chapter, you should be able to

  1. Describe the various methods of processing keyed files.

  2. Describe the various formats of the READ statement and demonstrate their use.

  3. Describe how the REWRITE statement is used to update a keyed file.

  4. Describe the use of the START statement and demonstrate its use.

  5. Describe and demonstrate how files are accessed dynamically.

ACCESSING A KEYED FILE RANDOMLY

With a keyed file we can access records either sequentially or randomly, depending on the user's needs. The term random access implies that records are to be processed or accessed in some order other than the one in which they were physically written on the disk.

When records are added to a keyed file, they are placed at the end of the data file. At the same time, an entry is added to the index file in the proper location to keep the index in sequence according to the key field or fields.

Keyed files may be accessed randomly to respond to special requests or inquiries or accessed randomly to verify the existence of a record and to update that record. Let us consider an example of random inquiries to a keyed file for the purpose of printing an employee request report. Figure 13.1 illustrates the processing involved.

Suppose managers submit daily requests for employee information required for the next business day. All requests submitted are grouped together and entered into one batch file called EMPLOYEE-QUERY-FILE.

Record ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Designing and Programming CICS Applications

Designing and Programming CICS Applications

John Horswill, Members of the CICS Development Team at IBM Hursley

Publisher Resources

ISBN: 9780471418467Purchase book