Dataset Attribute Cheat Sheet: LRECL, RECFM, BLKSIZE, GDG

Dataset attributes define how data is stored and accessed in mainframe datasets. Understanding LRECL (Logical Record Length), RECFM (Record Format), BLKSIZE (Block Size), and GDG (Generation Data Groups) is essential for working with datasets. This cheat sheet provides quick reference information for these critical attributes.

These attributes must be specified correctly when allocating datasets and must match when reading datasets. Incorrect attributes can cause data corruption, I/O errors, or application failures. This guide explains each attribute and provides common values and usage patterns.

LRECL: Logical Record Length

LRECL specifies the length of each logical record in bytes.

Definition

LRECL (Logical Record Length) is the length of each logical record in the dataset, measured in bytes. For fixed-length records, LRECL is the exact record length. For variable-length records, LRECL is the maximum record length including the 4-byte Record Descriptor Word (RDW).

Common Values

Common LRECL values and usage
LRECL ValueCommon UsageNotes
80Card images, standard COBOLTraditional punched card length
133Print lines with carriage control132 data bytes + 1 control byte
256Common application recordsWidely used for many applications
1024Larger recordsFor applications needing larger records
VariableVariable-length recordsLRECL includes 4-byte RDW (e.g., 84 for 80-byte data)

Important Notes

  • For fixed-length records (RECFM=F or FB), LRECL is the exact record length
  • For variable-length records (RECFM=V or VB), LRECL includes the 4-byte RDW
  • LRECL must match the actual record length when reading datasets
  • Maximum LRECL is typically 32,760 bytes
  • LRECL affects storage efficiency and I/O performance

RECFM: Record Format

RECFM specifies how records are organized and formatted in the dataset.

Definition

RECFM (Record Format) defines how records are stored in the dataset. It specifies whether records are fixed or variable length, whether they're blocked or unblocked, and whether they include control characters.

Common Formats

Common RECFM formats
RECFM ValueDescriptionCommon Usage
FFixed-length, unblockedSimple fixed records, one per block
FBFixed-length, blockedMost common for fixed records, multiple per block
VVariable-length, unblockedSimple variable records, one per block
VBVariable-length, blockedMost common for variable records, multiple per block
UUndefinedBinary data, no record structure
FBAFixed blocked with ANSI controlPrint files with ANSI carriage control
VBAVariable blocked with ANSI controlVariable print files with ANSI control

Format Components

  • F (Fixed): All records have the same length (LRECL)
  • V (Variable): Records can have different lengths (up to LRECL)
  • B (Blocked): Multiple records per physical block
  • A (ANSI): First byte is ANSI carriage control character
  • U (Undefined): No record structure, binary data

Blocked vs. Unblocked

Blocked formats (FB, VB) store multiple records per physical block, improving I/O efficiency. Unblocked formats (F, V) store one record per block, which is simpler but less efficient. Blocked formats are preferred for most applications because they reduce I/O operations and improve performance.

BLKSIZE: Block Size

BLKSIZE specifies the size of each physical block on disk.

Definition

BLKSIZE (Block Size) is the size of each physical block on disk, measured in bytes. Blocks are the physical units that the system reads and writes. For blocked formats (FB, VB), BLKSIZE should be a multiple of LRECL for efficiency.

Calculation Guidelines

  • For RECFM=FB: BLKSIZE should be a multiple of LRECL
  • For RECFM=VB: BLKSIZE should account for variable record lengths and BDW (Block Descriptor Word)
  • Maximum BLKSIZE is typically 32,760 bytes
  • Larger block sizes improve I/O performance but use more memory
  • BLKSIZE must fit within device limits

Common BLKSIZE Values

Common BLKSIZE values
BLKSIZETypical LRECLRecords per BlockNotes
800080100Common for card images
2792080349Larger blocks for better performance
3276080409Maximum for most devices
27920133210Common for print files

Performance Considerations

  • Larger blocks reduce I/O operations and improve performance
  • Blocks must fit in memory buffers, so very large blocks may not be practical
  • BLKSIZE should match device characteristics for optimal performance
  • For sequential access, larger blocks are generally better
  • For random access, smaller blocks may be more efficient

GDG: Generation Data Groups

GDGs (Generation Data Groups) are collections of related datasets with generation numbers.

Definition

A GDG (Generation Data Group) is a collection of related datasets that share a common base name but have generation numbers appended. Each time a new generation is created, it gets a higher number (e.g., DATASET.G0001V00, DATASET.G0002V00). GDGs allow you to maintain historical versions of datasets while always referencing the latest or specific generations.

GDG Naming Convention

GDG datasets use a naming convention with generation numbers:

  • Base Name: The common name (e.g., USERID.DATA)
  • Generation Number: Sequential number (e.g., G0001V00, G0002V00)
  • Absolute Generation: Specific generation (e.g., USERID.DATA.G0001V00)
  • Relative Generation: Relative reference (e.g., USERID.DATA(0) for latest, (-1) for previous)

GDG Index

GDGs require an index dataset that tracks generations:

  • Index name is typically the base name (e.g., USERID.DATA)
  • Index contains generation information and limits
  • Index must be allocated before creating GDG generations
  • Index tracks maximum number of generations to keep

Common GDG Operations

Common GDG operations
OperationDescriptionExample
Create IndexAllocate GDG indexIDCAMS DEFINE GDG
Create GenerationCreate new generationAllocate USERID.DATA(+1)
Reference LatestReference latest generationUSERID.DATA(0)
Reference PreviousReference previous generationUSERID.DATA(-1)
Delete GenerationDelete specific generationDelete USERID.DATA.G0001V00

GDG Use Cases

  • Backups: Maintain historical backup versions
  • Logs: Keep daily/weekly log files
  • Data Archives: Archive historical data versions
  • Reports: Maintain report generations
  • Data Processing: Track data processing generations

Attribute Relationships

LRECL, RECFM, and BLKSIZE must work together correctly.

Compatibility Rules

  • For RECFM=FB: BLKSIZE must be a multiple of LRECL
  • For RECFM=VB: BLKSIZE must account for variable record lengths and BDW
  • For RECFM=F or V: BLKSIZE typically equals LRECL (unblocked)
  • All attributes must match when reading datasets
  • Attributes must be compatible with device characteristics

Example Combinations

plaintext
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
RECFM=FB, LRECL=80, BLKSIZE=8000 - Fixed-length records, 80 bytes each - Blocked format, 100 records per block - Common for card images RECFM=VB, LRECL=256, BLKSIZE=27920 - Variable-length records, up to 256 bytes - Blocked format, multiple records per block - Common for application data RECFM=FBA, LRECL=133, BLKSIZE=27920 - Fixed-length records, 133 bytes each - Blocked format with ANSI control - Common for print files

Quick Reference Table

Quick reference for common attribute combinations:

Common attribute combinations
UsageRECFMLRECLBLKSIZE
Card ImagesFB808000
Print FilesFBA13327920
Application DataFB25627920
Variable DataVB25627920
Binary DataUN/A32760

Explain Like I'm 5: Dataset Attributes

Think of dataset attributes like rules for organizing your toys:

  • LRECL is like the size of each toy box. If all your toy boxes are the same size (fixed), LRECL tells you exactly how big each box is. If boxes can be different sizes (variable), LRECL tells you the biggest box size allowed!
  • RECFM is like the way you organize your toy boxes. You can put one box per shelf (unblocked) or stack many boxes on one shelf (blocked). You can also decide if all boxes are the same size (fixed) or different sizes (variable)!
  • BLKSIZE is like the size of each shelf. If you stack many toy boxes on a shelf (blocked), the shelf size should fit whole boxes - you don't want to cut a box in half! Bigger shelves can hold more boxes, which is more efficient!
  • GDG is like having numbered versions of your toy collection. Every time you get new toys, you put them in a new numbered box (G0001, G0002, etc.), but you always know which is the latest (0) or can go back to older versions (-1, -2)!

So dataset attributes are like rules for organizing your data - they tell you how big each record is, how records are organized, how big the storage blocks are, and how to manage multiple versions of your data!

Practice Exercises

Practice working with dataset attributes:

Exercise 1: Understanding LRECL

Objective: Understand LRECL values.

Steps:

  • Identify common LRECL values (80, 133, 256)
  • Understand when to use each value
  • Calculate LRECL for variable records (data length + 4)
  • Practice specifying LRECL when allocating datasets

Exercise 2: Understanding RECFM

Objective: Understand record formats.

Steps:

  • Learn the difference between F and V (fixed vs. variable)
  • Learn the difference between blocked and unblocked
  • Understand when to use each format
  • Practice specifying RECFM when allocating datasets

Exercise 3: Calculating BLKSIZE

Objective: Calculate appropriate BLKSIZE values.

Steps:

  • For RECFM=FB, calculate BLKSIZE as multiple of LRECL
  • Consider device limits (typically 32,760)
  • Balance performance vs. memory usage
  • Practice calculating BLKSIZE for different LRECL values

Test Your Knowledge

1. What does LRECL stand for?

  • Logical Record Length
  • Long Record Length
  • Line Record Length
  • Logical Record Limit

2. What does RECFM stand for?

  • Record Format
  • Record File Mode
  • Record Format Mode
  • Record File Method

3. What does BLKSIZE stand for?

  • Block Size
  • Block Storage
  • Block Structure
  • Block Segment

4. What does GDG stand for?

  • Generation Data Group
  • Group Data Generation
  • Generation Dataset Group
  • Group Dataset Generation

5. What is a common LRECL value for card images?

  • 80
  • 133
  • 256
  • 1024

Related Concepts