Module lessons (1/2)
FILE-CONTROL (SELECT) and FILE SECTION (FD)
Associate logical names with external datasets in ENVIRONMENT DIVISION, declare buffer FD/01 in FILE SECTION, and plot FILE STATUS.
What you'll learn in this lesson
- Link internal logical names and external files using
SELECT ... ASSIGN TOinsideENVIRONMENT DIVISION→INPUT-OUTPUT SECTION→FILE-CONTROL. - Choose the appropriate file organization (
LINE SEQUENTIALfor text lines vsSEQUENTIALbinary records) and always declareFILE STATUS. - Define the structure of the I/O records via entries
FD(File Description) in theFILE SECTIONof theDATA DIVISION.
Overview
Before relational databases, flat files were the absolute backbone of data processing: even today, millions of bank statements, SEPA traces and nightly batches flow on sequential files at very high speed.
In the COBOL world the program never hardcodes open("/var/data/file.txt") into the business logic. Instead, declare a symbolic contract inside FILE-CONTROL.:
Sections covered in this lesson
- 11. Logical-physical association (
ENVIRONMENT DIVISION) - 22. Buffer declaration (
DATA DIVISION→FILE SECTION) - 33. Buffer
FDvs Working Copies inWORKING-STORAGE - 4Try it yourself
Unlock "FILE-CONTROL (SELECT) and FILE SECTION (FD)" and the full Course COBOL curriculum
Associate logical names with external datasets in ENVIRONMENT DIVISION, declare buffer FD/01 in FILE SECTION, and plot FILE STATUS.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course COBOL plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.