MainframeMaster

JCL Tutorial

RECFM: Record Format Parameter

Progress0 of 0 lessons

What is RECFM?

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.

Syntax and Common Values

Syntax within DCB

jcl
1
//ddname DD ...,DCB=(...,RECFM=format,... )

The RECFM value is a combination of characters representing different attributes.

Common RECFM Codes

CodeAttributeDescription
FFormatFixed-length records. All records have the same length (specified by LRECL).
VFormatVariable-length records. Records can have different lengths, up to LRECL. Each record is preceded by a 4-byte Record Descriptor Word (RDW).
UFormatUndefined-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.
BBlockingBlocked records. Multiple logical records are grouped into a single physical block (size defined by BLKSIZE) for efficient I/O.
SBlockingSpanned records (for RECFM=V). A logical record can span across multiple blocks.
AControl CharacterASA control characters. The first byte of each record contains an ASA print control character (e.g., for spacing, skipping lines).
MControl CharacterMachine code control characters. The first byte contains machine control characters.

Common RECFM Combinations

RECFM=FB (Fixed Blocked)

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.

jcl
1
2
//FIXEDDS DD DSN=MY.FIXED.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920),...

RECFM=VB (Variable Blocked)

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).

jcl
1
2
//VARDDS DD DSN=MY.VARIABLE.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=VB,LRECL=255,BLKSIZE=27998),...

RECFM=F (Fixed Unblocked)

Fixed-length records where each block contains exactly one record. Inefficient for disk/tape I/O. LRECL must equal BLKSIZE.

jcl
1
2
//UNBLDS DD DSN=MY.UNBLOCKED.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=F,LRECL=100,BLKSIZE=100),...

RECFM=V (Variable Unblocked)

Variable-length records where each block contains exactly one record. LRECL is max record length + 4 (RDW), BLKSIZE is LRECL + 4 (BDW).

jcl
1
2
//VARUNB DD DSN=MY.VARUNBLK.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=V,LRECL=104,BLKSIZE=108),... // Max data = 100

RECFM=U (Undefined)

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.

jcl
1
2
//LOADLIB DD DSN=MY.PROD.LOADLIB,DISP=SHR, // DCB=RECFM=U,...

RECFM=FBA (Fixed Blocked with ASA)

Fixed-length blocked records where the first byte of each record is an ASA control character for printer formatting.

jcl
1
2
//PRTLINE DD SYSOUT=A, // DCB=(RECFM=FBA,LRECL=133,BLKSIZE=1330)

RECFM=VBS (Variable Blocked Spanned)

Variable-length blocked records where a single logical record can span across multiple physical blocks. Useful for very large variable records.

jcl
1
2
//SPANDDS DD DSN=MY.SPANNED.DATA,DISP=(NEW,CATLG), // DCB=(RECFM=VBS,LRECL=32756,BLKSIZE=27998),...

Choosing the Right RECFM

  • Use FB for datasets with consistent, fixed-size records (e.g., traditional card-image files, structured database extracts).
  • Use VB when record lengths vary significantly (e.g., text files, files with variable-length fields).
  • Use U primarily for load libraries or object modules.
  • Include B (Blocked) whenever possible (FB, VB) for I/O efficiency, especially on DASD and tape.
  • Use A or M only when creating datasets specifically intended for printers that recognize those control characters.
  • Use S (Spanned) only with V if logical records might exceed the optimal BLKSIZE.

Relationship with LRECL and BLKSIZE

RECFM, LRECL (Logical Record Length), and BLKSIZE (Block Size) are closely related:

  • RECFM=F/FB: LRECL defines the exact length of each record. BLKSIZE must be specified and, for FB, must be a multiple of LRECL.
  • RECFM=V/VB/VBS: LRECL defines the maximum length of a logical record (including the 4-byte RDW). BLKSIZE defines the maximum length of a block (including the 4-byte BDW for blocked formats). BLKSIZE must be at least LRECL + 4 for VB/VBS.
  • RECFM=U: LRECL is usually 0 or omitted. BLKSIZE defines the physical block size and is required.

Choosing an optimal BLKSIZE (often half-track blocking or letting the system determine it via BLKSIZE=0) is crucial for performance.

RECFM Exercises

Exercise 1: Code DCB for Fixed Records

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).

Exercise 2: Code DCB for Variable Records

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).

Frequently Asked Questions

What happens if RECFM is incorrect when reading a file?

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.

Can RECFM be omitted?

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.

What is the difference between LRECL for RECFM=F and RECFM=V?

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).

Test Your Knowledge

1. Which RECFM code indicates fixed-length records?

  • V
  • U
  • F
  • B

2. What does the 'B' in RECFM=FB or RECFM=VB stand for?

  • Backup
  • Binary
  • Blocked
  • Buffer

3. For RECFM=VB, what does the LRECL value represent?

  • The exact length of each record
  • The maximum length of the data portion of a record
  • The maximum length of a record including the 4-byte RDW
  • The block size

4. Which RECFM is typically used for load libraries (executable programs)?

  • FB
  • VB
  • U
  • FBA

5. What must be true about BLKSIZE for RECFM=FB?

  • It must be larger than LRECL
  • It must be equal to LRECL
  • It must be a multiple of LRECL
  • It can be omitted