Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide

KEYLOC

The KEYLOC option specifies the starting position, n, of the embedded key in records of a KEYED file. You can specify KEYLOC only for INDEXED files (see ORGANIZATION later in this section).

Read syntax diagramSkip visual syntax diagram>>-KEYLOC--(n)-------------------------------------------------><
 

The position, n, must be within the limits:

1 <= n <= recordsize - keylength + 1

That is, the key cannot be larger than the record and must be contained completely within the record.

This means that if you specify the SCALARVARYING option, the embedded key must not overlap the first two bytes of the record; hence, the value you specify for KEYLOC must be greater than 2.

If you do not specify KEYLOC when creating an indexed data set, the key is assumed to start with the first byte of the record.

If you include the KEYLOC option in a file declaration, and the associated data set already exists, the value is used for checking purposes. If the key position you specify in the option conflicts with the value defined for the data set, the UNDEFINEDFILE condition is raised.

ISAM and BTRIEVE
Keys are kept in the index pages of an ISAM or BTRIEVE file. The location of the key needs to be defined to PL/I when the file is created.
Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide