../courses.php
COBOL
COBOL108
3
Reading Files
Much of COBOL's work involves reading one business record after another.
Why are files so important in COBOL?
COBOL processes large collections of business records stored in files, often one record at a time.
Business information usually lives in files.
Payroll records.
Customer records.
Account records.
COBOL was designed to process these files efficiently.
Reading one record
OPEN INPUT CUSTOMER-FILE.
READ CUSTOMER-FILE
AT END
DISPLAY "END OF FILE"
END-READ.
CLOSE CUSTOMER-FILE.
OPEN prepares the file.
READ requests the next record.
AT END detects when no more records exist.
END-READ finishes the READ statement.
CLOSE finishes work with the file.
Records
Most COBOL processing is record based.
Reliability
Business files must be processed carefully.
Batch jobs
Large overnight jobs often process thousands of records.
Foundation
File processing is one of COBOL's greatest strengths.
Reading without opening
Correct sequence
Ask ChatGPT: "Explain the life cycle of this COBOL file from OPEN through CLOSE."
Open a file.
Read one record.
Handle AT END.
Close the file.
Explain why the order matters.
Reading before OPEN.
Ignoring AT END.
Forgetting CLOSE.
Assuming every READ succeeds.
Ignoring file processing errors.
Explain the basic OPEN → READ → CLOSE flow used in COBOL file processing.
Login - Jit4All
Login
Welcome back to Jit4All