Specify key fields from different files

A dynamic keyed sequence access path over a join logical file allows you to specify a processing sequence in which the keys can be in different physical files (DDS restricts the keys to the primary file).

The specification is identical to the previous method. The access path is specified using whatever key fields are required. There is no restriction on which physical file the key fields are in. However, if a key field exists in other than the primary file of a join specification, the system must make a temporary copy of the joined records. The system must also build a keyed sequence access path over the copied records before the query file is opened. The key fields must exist in the format identified on the FORMAT parameter.

Example: Specify key fields from different files

This example shows how to use a field in a secondary file as a key field.

Assume that you already have a join logical file named JOINLF. FILEX is specified as the primary file and is joined to FILEY. You want to process the records in JOINLF by the Descrp field which is in FILEY.

Assume that the file record formats contain the following fields:

FILEX FILEY JOINLF
Item Item Item
Qty Descrp Qty
    Descrp
You can specify:
OVRDBF    FILE(JOINLF) SHARE(*YES)
OPNQRYF   FILE(JOINLF) KEYFLD(DESCRP)
CALL      PGM(PGMC)
CLOF      OPNID(JOINLF)
DLTOVR    FILE(JOINLF)
If you want to arrange the records by Qty in Descrp (Descrp is the primary key field and Qty is a secondary key field) you can specify:
OPNQRYF   FILE(JOINLF) KEYFLD(DESCRP QTY)