File Handling, Sequential Files, Indexed Files, and Record Processing
Understand one of COBOL’s strongest domains: structured file-based business data processing.
Inside this chapter
- Why File Processing Is Central in COBOL
- Sequential File Processing
- READ and WRITE Patterns
- Indexed Files
- Business Example
Series navigation
Study the chapters in order for the clearest path from COBOL basics to enterprise batch processing, operational context, and modernization strategy. Use the navigation at the bottom to move smoothly through the full tutorial series.
Why File Processing Is Central in COBOL
Many COBOL programs are built around reading large files, transforming records, validating business rules, and writing outputs. Even in systems with databases and online transactions, file-based batch workflows remain important.
Sequential File Processing
Sequential files are processed record by record in order. This is common for payroll batches, daily transaction files, billing runs, and report-generation jobs.
READ and WRITE Patterns
READ INPUT-FILE
AT END
MOVE "Y" TO END-OF-FILE-SWITCH
END-READ.
Programs often loop until an end-of-file condition is reached, processing each record in turn.
Indexed Files
Indexed files support keyed access and are useful when records need to be retrieved by identifiers such as account numbers or policy numbers instead of only sequential order.
Business Example
A utility billing system may read customer usage records sequentially, calculate bill amounts, and write invoice outputs. Another program may use indexed access to retrieve a specific customer account by key for online inquiry or adjustment processing.