JREF (Join Reference) keyword—join logical files only

Use this field-level keyword in join logical files for fields whose names are specified in more than one physical file. This keyword identifies which physical file contains the field.

The format of the keyword is:
JREF(file-name | relative-file-number)

You can specify either the physical file name or its relative file number. If a physical file is named twice on the JFILE keyword, then you must specify the relative file number. The relative file number corresponds to the physical file name specified on the JFILE keyword. For example, specifying JREF(1) associates a field with the first physical file specified on the JFILE keyword. Specifying JREF(2) associates a field with the second physical file specified on the JFILE keyword. See example 2 in this topic.

This keyword is valid only in a join logical file.

Join logical files are based on two or more physical files (up to 256). Field names specified in the record format in a join logical file must uniquely identify only one field from the physical files on which the join logical file is based. For example, if the join logical file is based on two physical files, and each physical file has the field named NAME, you must specify the JREF keyword to identify which physical file the field comes from.

When a field name is unique among the physical files specified on the JFILE keyword, this keyword is optional. For example, if the join logical file is associated with two physical files, and only one of the physical files has a field named NAME1, you do not need to specify the JREF keyword.

If the join logical file is associated with only one physical file (the JFILE keyword names the same file twice), you must specify the JREF keyword on every field.

Example 1

The following examples show how to specify the JREF keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R JOINREC                   JFILE(PFA PFB PFC)
00020A               :
00030A               :
00040A               :
00050A            NAME                      JREF(PFB)
     A

In this example, the JREF keyword is specified with the file name, and NAME occurs in both PFA and PFB. Specifying JREF (PFB) associates this field with PFB.

Example 2

The following example shows how to use the file reference numbers to specify JREF.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R JOINREC                   JFILE(PFA PFB PFC)
00020A               :
00030A               :
00040A               :
00050A            NAME                      JREF(2)
     A

Example 2 is equivalent to example 1. In example 2, NAME occurs in both PFA and PFB. Specifying JREF(2) associates this field with PFB (the second of the physical files specified on the JFILE keyword).