DD KEYLEN Parameter


Note! KEYLEN parameter is required only when we are creating a dataset.

The KEYLEN parameter is used to specify the key length while creating the new dataset. The KEYLEN parameter is optional. If KEYLEN is not coded, the dataset does not have any keys.

KEYLEN applies to BDAM, BPAM, BSAM, EXCP, and QSAM access methods and to VSAM datasets with SMS.

Syntax -

KEYLEN=bytes
bytes Specifies the key length in bytes.
The key length is 0 to 255 for non-VSAM datasets and 1 to 255 for VSAM KSDS.
The key length should be less than or equal to the record length.

Examples -


Scenario1 - Creating new dataset of key length 8.

//DD01  DD  DSN=MTH.DATA.PS,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=3390,
//            SPACE=(CYL,(12,2),RLSE),
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=1600),
//            KEYLEN=8

Scenario2 - VSAM dataset key length 6 bytes.

//DD01  DD  DSN=MTH.VSAM.DATA,
//          DATACLAS=VSAM1,
//          DISP=(NEW,KEEP),
//          KEYLEN=6