Fields from physical files that you are using as join fields generally have the same attributes (length, data type, and decimal positions). For example, as in Figure 14, the Name1 field is a character field 10 characters long in physical file PF1, and can be joined to the Name2 field, a character field 10 characters long in physical file PF2. The Name1 and Name2 fields have the same characteristics and, therefore, can easily be used as join fields.
You can also use character type fields that have different lengths as join fields without requiring any redefinition of the fields. For example, if the NAME1 Field of PF1 was 10 characters long and the NAME2 field of PF2 was 15 characters long, those fields could be used as join fields without redefining one of the fields.
The following is an example in which the join fields do not have the same attributes. The Nbr field in physical file PF1 and the Nbr field in physical file PF2 both have a length of 3 specified in position 34, but in the PF1 file the field is zoned (S in position 35), and in the PF2 file the field is packed (P in position 35). To join the two files using these fields as join fields, you must redefine one or both fields to have the same attributes.
The following illustrates the fields in the logical and physical
files:

The DDS for these files is as follows:
JLF
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A R JOINREC JFILE(PF1 PF2)
A J JOIN(PF1 PF2)
A JFLD(NBR NBR)
A NBR S JREF(2)
A NAME
A SALARY
A
PF1
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A R REC1
A NBR 3S 0 <-Zoned
A NAME 20
A K NBR
A
PF2
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A R REC2
A NBR 3P 0 <-Packed
A SALARY 7 2
A K NBR
A
| Note: | In this example, the Nbr field in the logical file comes from PF2, because JREF(2) is specified. Instead of specifying the physical file name, you can specify a relative file number on the JREF keyword; in this example, the 2 indicates PF2. |
Because the Nbr fields in the PF1 and PF2 files are used as the join fields, they must have the same attributes. In this example, they do not. Therefore, you must redefine one or both of them to have the same attributes. In this example, to resolve the difference in the attributes of the two employee number fields, the Nbr field in JLF (which is coming from the PF2 file) is redefined as zoned (S in position 35 of JLF).