Summary -

In this topic, we described about the DD KEYLEN with detailed example.

KEYLEN parameter used to specify the length of the key used in new dataset.KEYLEN parameter is an optional parameter.If KEYLEN is not specified, the dataset must not require any keys.

KEYLEN applies to data sets with the BDAM, BPAM, BSAM, EXCP and QISAM access methods and to VSAM data sets with SMS.

Syntax -


bytes Specifies the key length in bytes.
Key length is 0 to 255 for non-VSAM data sets.
The key length must be less than or equal to the record length.
Key length is 1 to 255 for VSAM key-sequenced (RECORG=KS) data sets.
Note! Use only 0 for a member of a partitioned data set extended (PDSE).

Example 1:

//            SPACE=(CYL,(12,2)),KEYLEN=8

DD statement DD01 defines a new data set named MTH.DATA with the key length 8 bytes.

Example 2:

//          KEYLEN=6

In the example, where the data class VSAM1 defines a key-sequenced VSAM data set, the key length of 6 overrides the key length defined in the data class.