RECFM (Record Format) is a subparameter of the Data Control Block (DCB) parameter in JCL. It specifies the format and characteristics of the records within a dataset. Defining the correct RECFM is essential for the operating system and application programs to correctly read and write data.
RECFM controls whether records are fixed-length, variable-length, or undefined, and also includes attributes related to blocking and control characters.
1//ddname DD ...,DCB=(...,RECFM=format,... )
The RECFM value is a combination of characters representing different attributes.
Code | Attribute | Description |
---|---|---|
F | Format | Fixed-length records. All records have the same length (specified by LRECL). |
V | Format | Variable-length records. Records can have different lengths, up to LRECL. Each record is preceded by a 4-byte Record Descriptor Word (RDW). |
U | Format | Undefined-length records. Records have no specific format; the program is responsible for interpreting the data. Often used for load modules or object code. LRECL is typically not coded, BLKSIZE is required. |
B | Blocking | Blocked records. Multiple logical records are grouped into a single physical block (size defined by BLKSIZE) for efficient I/O. |
S | Blocking | Spanned records (for RECFM=V). A logical record can span across multiple blocks. |
A | Control Character | ASA control characters. The first byte of each record contains an ASA print control character (e.g., for spacing, skipping lines). |
M | Control Character | Machine code control characters. The first byte contains machine control characters. |
The most common format for structured data files. All records have the same fixed length (LRECL), and multiple records are grouped into blocks (BLKSIZE). BLKSIZE must be an exact multiple of LRECL.
12//FIXEDDS DD DSN=MY.FIXED.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920),...
Used when record lengths vary. Each record is prefixed by a 4-byte RDW. Multiple records (plus their RDWs) and a 4-byte Block Descriptor Word (BDW) are grouped into blocks. LRECL specifies the maximum record length (including the RDW), and BLKSIZE specifies the maximum block size (including the BDW).
12//VARDDS DD DSN=MY.VARIABLE.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=VB,LRECL=255,BLKSIZE=27998),...
Fixed-length records where each block contains exactly one record. Inefficient for disk/tape I/O. LRECL must equal BLKSIZE.
12//UNBLDS DD DSN=MY.UNBLOCKED.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=F,LRECL=100,BLKSIZE=100),...
Variable-length records where each block contains exactly one record. LRECL is max record length + 4 (RDW), BLKSIZE is LRECL + 4 (BDW).
12//VARUNB DD DSN=MY.VARUNBLK.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=V,LRECL=104,BLKSIZE=108),... // Max data = 100
Used for data with no specific record structure, like executable load modules. The program reading/writing the data defines the structure. BLKSIZE is required; LRECL is usually omitted or zero.
12//LOADLIB DD DSN=MY.PROD.LOADLIB,DISP=SHR, // DCB=RECFM=U,...
Fixed-length blocked records where the first byte of each record is an ASA control character for printer formatting.
12//PRTLINE DD SYSOUT=A, // DCB=(RECFM=FBA,LRECL=133,BLKSIZE=1330)
Variable-length blocked records where a single logical record can span across multiple physical blocks. Useful for very large variable records.
12//SPANDDS DD DSN=MY.SPANNED.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=VBS,LRECL=32756,BLKSIZE=27998),...
RECFM, LRECL (Logical Record Length), and BLKSIZE (Block Size) are closely related:
Choosing an optimal BLKSIZE (often half-track blocking or letting the system determine it via BLKSIZE=0) is crucial for performance.
Write the DCB parameter for a new dataset containing fixed-length records of 100 bytes each. Choose an appropriate block size for efficiency (e.g., 27900).
Write the DCB parameter for a new dataset containing variable-length records, with a maximum logical record length of 500 bytes (including RDW). Use blocking and choose a suitable block size (e.g., 27998).
Reading a file with the wrong RECFM usually leads to I/O errors (e.g., S001 or S002 abend), incorrect data interpretation, or unexpected program behavior. The system relies on RECFM to correctly deblock records and determine record boundaries.
It can be omitted if the program opening the dataset provides the RECFM, or if reading an existing cataloged dataset where RECFM is stored in the catalog/VTOC. However, it's best practice to explicitly code DCB attributes (including RECFM, LRECL, BLKSIZE) when creating new datasets to avoid ambiguity and reliance on defaults.
For RECFM=F, LRECL is the exact length of the data in each record. For RECFM=V, LRECL is the maximum length of the data *plus* the 4-byte Record Descriptor Word (RDW).
1. Which RECFM code indicates fixed-length records?
2. What does the 'B' in RECFM=FB or RECFM=VB stand for?
3. For RECFM=VB, what does the LRECL value represent?
4. Which RECFM is typically used for load libraries (executable programs)?
5. What must be true about BLKSIZE for RECFM=FB?