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 specifies the length of each logical record in bytes.
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).
| LRECL Value | Common Usage | Notes |
|---|---|---|
| 80 | Card images, standard COBOL | Traditional punched card length |
| 133 | Print lines with carriage control | 132 data bytes + 1 control byte |
| 256 | Common application records | Widely used for many applications |
| 1024 | Larger records | For applications needing larger records |
| Variable | Variable-length records | LRECL includes 4-byte RDW (e.g., 84 for 80-byte data) |
RECFM specifies how records are organized and formatted in the dataset.
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.
| RECFM Value | Description | Common Usage |
|---|---|---|
| F | Fixed-length, unblocked | Simple fixed records, one per block |
| FB | Fixed-length, blocked | Most common for fixed records, multiple per block |
| V | Variable-length, unblocked | Simple variable records, one per block |
| VB | Variable-length, blocked | Most common for variable records, multiple per block |
| U | Undefined | Binary data, no record structure |
| FBA | Fixed blocked with ANSI control | Print files with ANSI carriage control |
| VBA | Variable blocked with ANSI control | Variable print files with ANSI control |
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 specifies the size of each physical block on disk.
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.
| BLKSIZE | Typical LRECL | Records per Block | Notes |
|---|---|---|---|
| 8000 | 80 | 100 | Common for card images |
| 27920 | 80 | 349 | Larger blocks for better performance |
| 32760 | 80 | 409 | Maximum for most devices |
| 27920 | 133 | 210 | Common for print files |
GDGs (Generation Data Groups) are collections of related datasets with generation numbers.
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 datasets use a naming convention with generation numbers:
GDGs require an index dataset that tracks generations:
| Operation | Description | Example |
|---|---|---|
| Create Index | Allocate GDG index | IDCAMS DEFINE GDG |
| Create Generation | Create new generation | Allocate USERID.DATA(+1) |
| Reference Latest | Reference latest generation | USERID.DATA(0) |
| Reference Previous | Reference previous generation | USERID.DATA(-1) |
| Delete Generation | Delete specific generation | Delete USERID.DATA.G0001V00 |
LRECL, RECFM, and BLKSIZE must work together correctly.
12345678910111213141516RECFM=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 for common attribute combinations:
| Usage | RECFM | LRECL | BLKSIZE |
|---|---|---|---|
| Card Images | FB | 80 | 8000 |
| Print Files | FBA | 133 | 27920 |
| Application Data | FB | 256 | 27920 |
| Variable Data | VB | 256 | 27920 |
| Binary Data | U | N/A | 32760 |
Think of dataset attributes like rules for organizing your toys:
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 working with dataset attributes:
Objective: Understand LRECL values.
Steps:
Objective: Understand record formats.
Steps:
Objective: Calculate appropriate BLKSIZE values.
Steps:
1. What does LRECL stand for?
2. What does RECFM stand for?
3. What does BLKSIZE stand for?
4. What does GDG stand for?
5. What is a common LRECL value for card images?