File description
The FD entry that describes the records of a file, so the program can read them.
Also written FD, FILE SECTION, SELECT
Why it matters. Batch programs read and write files all day. The FD tells the program what one record looks like.
See it
ACCTIN is the DD name. JCL connects it to a real dataset.
Syntax
SELECT file-name ASSIGN TO ddname [FILE STATUS IS status-field]. FD file-name [BLOCK CONTAINS 0 RECORDS] [RECORD CONTAINS n CHARACTERS] [RECORDING MODE IS F].
- ASSIGN TO ddname
- The name of the DD statement in the JCL.
- FILE STATUS
- A two-character field that gets the result of every file statement.
- BLOCK CONTAINS 0 RECORDS
- Let the system choose the block size from the JCL or dataset.
- RECORD CONTAINS
- The record length. A mismatch with the dataset gives file status 39.
- RECORDING MODE
- Fixed (F) or variable (V) records.
Try it FD
- 1
In the FILE SECTION of the program ACCTCNT, describe the file ACCOUNTS-FILE. The record layout is written below it.
COBOL FD ACCOUNTS-FILE. - 2
Submit the job ACCTCNT from your DEV JCL library. It compiles the program and runs it.
SUBMIT 'ZB0001.DEV.JCL(ACCTCNT)' - 3
Read the output of the job. Find how many records it read.
OUTPUT ACCTCNT
Remember
- FD describes the records of one file.
- SELECT ... ASSIGN TO ddname links the file to a DD in the JCL. A FILE STATUS field lets the program test the result of each file statement.
- The program names a DD, not a dataset, so the same program can read different files.
The usual mistake
ASSIGN TO ACCTFILE in the program, but no //ACCTFILE DD in the JCL
The program asks for ACCTFILE and finds no DD with that name. The OPEN fails. With no FILE STATUS field to test, Language Environment ends the run with message IGZ0035S and abend U4038.
Use the same name in both: ASSIGN TO ACCTFILE and //ACCTFILE DD
On real z/OS
MF/OS reads sequential and basic indexed files. Several 01 records under one FD aren't shared as they are on z/OS (only the first is the record), and alternate keys and relative-file random access aren't functional.
Where can I practise File description?
Right here, at ZedBank. You take a junior job at a simulated bank and use File description in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- DATA DIVISIONThe part of a COBOL program that declares every record layout and variable it will use.
- DD statementThe JCL statement that connects a name inside a program to a real dataset outside it.
- KSDSThe most common VSAM dataset type, where every record has a unique key used to find it directly.
- Sequential datasetThe simplest kind of dataset: records stored one after another and normally read from start to finish.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- VSAMA family of dataset types built for fast record access by key, used where applications need to look records up rather than read them in order.