Record format
Says whether all records are the same length or not, and whether they are grouped in blocks. It is written RECFM.
Also written RECFM, record type
Why it matters. Every program that opens a file relies on its record format. A wrong one makes a job fail or read nonsense.
Syntax
ALLOCATE DATASET('name') NEW RECFM(V B) LRECL(n)
//ddname DD DSN=name,DISP=(NEW,CATLG),RECFM=VB,LRECL=255- F
- Fixed length.
- V
- Variable length. Each record starts with a 4-byte length field.
- B
- Blocked: several records in each block.
- A
- The first character of each record is a print control (ASA).
- U
- Undefined: used for load modules.
- S
- Spanned: records can cross block ends.
Try it ALLOC
- 1
Look at the details of the account file, ZBANK.DATA.ACCOUNTS. Find its record format.
LISTDS 'ZBANK.DATA.ACCOUNTS' - 2
Make a log file, ZB0001.DEV.TXNLOG, with variable blocked records of up to 255 characters.
ALLOC DSN('ZB0001.DEV.TXNLOG') NEW DSORG(PS) RECFM(V,B) LRECL(255) - 3
Look at the details of the log file.
LISTDS 'ZB0001.DEV.TXNLOG'
Remember
- F is fixed length. V is variable length, and its LRECL counts a 4-byte length field, so LRECL 255 holds 251 bytes of data.
- B is blocked: several records in one block.
- A at the end means the first character is a print control.
The usual mistake
RECFM(F,B) for a file of short and long lines
Every record is padded or cut to the same length. Short lines waste space and long ones do not fit.
RECFM(V,B) with LRECL set to the longest line
On real z/OS
ALLOCATE here fills in FB and 80 when you leave them out, and the space figures are accepted but not modelled. Real z/OS takes them from your options, or from a data class on a storage-managed system, and a bad combination is refused by the system or fails when the file is opened. For V files, LRECL counts the 4-byte length field at the front of the record, so LRECL 255 holds 251 bytes of data. Whether MF/OS applies that rule when it checks a program's record is not modelled.
Where can I practise Record format?
Right here, at ZedBank. You take a junior job at a simulated bank and use Record format in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- Logical record lengthHow long each record in a dataset is, in characters, written as LRECL.
- Block sizeHow much data is moved between disk and memory in one go, written as BLKSIZE.
- DatasetWhat a mainframe calls a file: a named collection of records with a defined structure, rather than a loose stream of bytes.
- Sequential datasetThe simplest kind of dataset: records stored one after another and normally read from start to finish.