LRECL Parameter

Purpose

The LRECL (Logical RECord Length) parameter defines the length, in bytes, of each logical record in a dataset. This parameter is crucial for proper data storage and retrieval, as it ensures that programs correctly interpret the boundaries between consecutive records.

Key Benefit:

Properly specified LRECL ensures data integrity and enables efficient processing. It defines the maximum size of records that can be stored in a dataset and affects both storage requirements and access methods.

Where LRECL is Used

  • In DD statements as part of the DCB parameter
  • In IDCAMS DEFINE commands (as RECORDSIZE)
  • In TSO ALLOCATE commands
  • In the DCB macro for assembler programs
  • In dynamic allocation services (SVC 99)
  • Within SMS data class definitions

Basic Syntax

jcl
1
2
3
//ddname DD DSN=dataset.name, // DCB=(LRECL=nnnnn,...), // ...other parameters...

Where nnnnn is the length of each logical record in bytes.

VSAM Syntax (RECORDSIZE)

jcl
1
2
3
4
5
//SYSIN DD * DEFINE CLUSTER (NAME(dataset.name) RECORDSIZE(average maximum) ...other parameters...) /*

For VSAM datasets, LRECL is specified using the RECORDSIZE parameter, which takes both an average and maximum value.

LRECL Value Ranges

Dataset TypeRECFMMinimumMaximum
Non-VSAMF, FB132,760
Non-VSAMV, VB532,756
Non-VSAMVS, VBS532,760
Non-VSAMU032,760
VSAM KSDSN/A132,761
VSAM ESDS/RRDSN/A132,761

Note:

For variable-length records (V, VB, VS, VBS), the LRECL value includes the 4-byte Record Descriptor Word (RDW), so the maximum data length is actually LRECL-4 bytes.

LRECL and RECFM Interaction

LRECL has specific meanings depending on the record format (RECFM) used:

RECFMLRECL InterpretationConsiderations
F, FBExact length of each recordAll records must have exactly this length
V, VBMaximum record length, including 4-byte RDWRecords can be shorter but not longer than LRECL
VS, VBSMaximum length of a record segment in a blockActual records can span multiple blocks and exceed LRECL
UNot meaningful (typically set to 0)Record length determined by block size or actual I/O operation

Common LRECL Values

Dataset TypeTypical LRECLNotes
Source code libraries80Traditional card image format
Print files (standard)133132 characters plus 1 carriage control byte
Print files (wide)151150 characters plus 1 carriage control byte
VSAM KSDSVariesBased on application data requirements
Sequential data filesVariesCommonly multiples of 4 or 8 for alignment
Log files1024-4096Often variable-length to accommodate varying message lengths

Usage Examples

Source Code Library

jcl
1
2
3
4
//SRCLIB DD DSN=USER.SOURCE.LIB, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,5,50)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920)

This example creates a partitioned dataset for source code with fixed-length 80-byte records, the standard format for source code libraries.

Print File

jcl
1
2
3
4
//REPORT DD DSN=USER.MONTHLY.REPORT, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(1,1)), // DCB=(RECFM=FBA,LRECL=133,BLKSIZE=13300)

This example defines a report file with ASA carriage control characters. The LRECL is 133 bytes: 1 byte for the ASA control character plus 132 bytes for the print line.

Variable-Length Log File

jcl
1
2
3
4
//LOGFILE DD DSN=USER.APPLICATION.LOG, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,2)), // DCB=(RECFM=VB,LRECL=1028,BLKSIZE=32760)

This example creates a log file with variable-length records. The LRECL is 1028 bytes, which means each record can contain up to 1024 bytes of actual data plus the 4-byte RDW.

VSAM KSDS Dataset

jcl
1
2
3
4
5
6
7
8
9
//IDCAMS EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER (NAME(USER.CUSTOMER.FILE) - RECORDSIZE(200 500) - INDEXED - KEYS(16 0) - CYLINDERS(5 2)) /*

In this VSAM KSDS example, RECORDSIZE(200 500) specifies an average record length of 200 bytes and a maximum of 500 bytes.

TSO ALLOCATE Command

jcl
1
2
ALLOC F(MYFILE) DA('USER.DATA.FILE') NEW SPACE(1,1) TRACKS - RECFM(FB) LRECL(80) BLKSIZE(27920)

This example shows specifying LRECL in a TSO ALLOCATE command, creating a new dataset with 80-byte fixed-length records.

LRECL Calculation Guidelines

  • Fixed-Length Records: LRECL = actual data length
    • For print files with carriage control: LRECL = print line width + 1
  • Variable-Length Records: LRECL = maximum data length + 4 (for RDW)
    • For print files with carriage control: LRECL = print line width + 1 + 4
  • VSAM KSDS: Consider average and maximum record sizes
    • Average RECORDSIZE = typical record length
    • Maximum RECORDSIZE = largest possible record

Space Considerations

LRECL directly affects space requirements. For fixed-length records, calculating space is straightforward:

Space calculation for FB datasets:

Total bytes = Number of records × LRECL

Tracks required = Total bytes ÷ Track capacity

Example:

10,000 records with LRECL=80:

10,000 × 80 = 800,000 bytes

For 3390 disk (approximately 56,664 bytes per track):

800,000 ÷ 56,664 ≈ 14.1 tracks (rounded up to 15 tracks)

Common Issues and Troubleshooting

IssuePossible CausesSolutions
ABEND002-04Attempting to write a record larger than LRECL
  • Increase LRECL to accommodate larger records
  • Modify program to limit record size
ABEND013-18LRECL mismatch between JCL and dataset
  • Check actual dataset attributes with LISTCAT or ISPF 3.2
  • Modify JCL to match dataset LRECL
Data truncationLRECL too small for data
  • Increase LRECL
  • For VS/VBS, ensure proper record spanning
Wasted spaceLRECL significantly larger than needed
  • Use appropriate LRECL for data
  • Consider variable-length records if sizes vary greatly
Performance issuesPoor LRECL/BLKSIZE relationship
  • Set BLKSIZE to a multiple of LRECL for FB records
  • Use system-determined BLKSIZE where appropriate

LRECL and Programming Languages

Different programming languages handle LRECL in specific ways:

LanguageLRECL Handling
COBOL
cobol
1
2
3
4
5
6
7
8
FD CUSTOMER-FILE RECORD CONTAINS 200 CHARACTERS BLOCK CONTAINS 0 RECORDS RECORDING MODE IS F. 01 CUSTOMER-RECORD. 05 CUSTOMER-ID PIC X(10). 05 CUSTOMER-NAME PIC X(30). ... (remaining fields)
PL/I
pli
1
2
3
4
5
DCL CUSTOMER_FILE FILE RECORD INPUT ENV(FB BLKSIZE(6000) RECSIZE(200)); DCL 1 CUSTOMER_RECORD, 2 CUSTOMER_ID CHAR(10), 2 CUSTOMER_NAME CHAR(30), ... (remaining fields);
Assembler
asm
1
2
CUSTFILE DCB DSORG=PS,MACRF=(GM),DDNAME=CUSTDD, X RECFM=FB,LRECL=200,BLKSIZE=6000

Best Practices

  1. Use Appropriate LRECL Values: Choose LRECL based on the actual data requirements, not arbitrarily large values.
  2. Consider Future Growth: Allow some room for expansion if fields might be added to records in the future.
  3. Optimize for Storage: For fixed-length records, select an LRECL that minimizes wasted space.
  4. Variable vs. Fixed Decision: Use variable-length records (V, VB) when record sizes vary significantly to save space.
  5. VSAM Average and Maximum: For VSAM KSDS with RECORDSIZE, set realistic average and maximum values for optimal performance.
  6. Consistent Definitions: Use the same LRECL value in all JCL and programs that access the same dataset.
  7. Documentation: Document LRECL values and record layouts for all datasets to facilitate maintenance.
  8. Track Capacity Awareness: Be mindful of track capacity limits when selecting LRECL values for efficient storage.

JES2 vs JES3 Considerations

LRECL is part of the data management system rather than the job entry subsystem, so it functions identically in both JES2 and JES3 environments. Both systems respect the same LRECL specifications in JCL.

Note:

For SYSOUT datasets, JES2 and JES3 handle the data similarly regardless of LRECL specification. However, if the SYSOUT is processed by an external writer, the LRECL value might be important.

Related Concepts