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.
123//ddname DD DSN=dataset.name, // DCB=(LRECL=nnnnn,...), // ...other parameters...
Where nnnnn
is the length of each logical record in bytes.
12345//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.
Dataset Type | RECFM | Minimum | Maximum |
---|---|---|---|
Non-VSAM | F, FB | 1 | 32,760 |
Non-VSAM | V, VB | 5 | 32,756 |
Non-VSAM | VS, VBS | 5 | 32,760 |
Non-VSAM | U | 0 | 32,760 |
VSAM KSDS | N/A | 1 | 32,761 |
VSAM ESDS/RRDS | N/A | 1 | 32,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 has specific meanings depending on the record format (RECFM) used:
RECFM | LRECL Interpretation | Considerations |
---|---|---|
F, FB | Exact length of each record | All records must have exactly this length |
V, VB | Maximum record length, including 4-byte RDW | Records can be shorter but not longer than LRECL |
VS, VBS | Maximum length of a record segment in a block | Actual records can span multiple blocks and exceed LRECL |
U | Not meaningful (typically set to 0) | Record length determined by block size or actual I/O operation |
Dataset Type | Typical LRECL | Notes |
---|---|---|
Source code libraries | 80 | Traditional card image format |
Print files (standard) | 133 | 132 characters plus 1 carriage control byte |
Print files (wide) | 151 | 150 characters plus 1 carriage control byte |
VSAM KSDS | Varies | Based on application data requirements |
Sequential data files | Varies | Commonly multiples of 4 or 8 for alignment |
Log files | 1024-4096 | Often variable-length to accommodate varying message lengths |
1234//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.
1234//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.
1234//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.
123456789//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.
12ALLOC 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 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)
Issue | Possible Causes | Solutions |
---|---|---|
ABEND002-04 | Attempting to write a record larger than LRECL |
|
ABEND013-18 | LRECL mismatch between JCL and dataset |
|
Data truncation | LRECL too small for data |
|
Wasted space | LRECL significantly larger than needed |
|
Performance issues | Poor LRECL/BLKSIZE relationship |
|
Different programming languages handle LRECL in specific ways:
Language | LRECL Handling |
---|---|
COBOL | cobol
|
PL/I | pli
|
Assembler | asm
|
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.