JOINKEYS Control Statement - mfx - 3.1

Syncsort™ MFX Programmers Guide

Product type
Software
Portfolio
Integrate
Product family
Syncsort™ Software
Product
Syncsort™ MFX > MFX
Version
3.1
Language
English
Content type
Programmer’s Guide
Product name
Syncsort™ MFX
Title
Syncsort™ MFX Programmers Guide
Copyright
2024
First publish date
2010
Last updated
2024-11-06
Published on
2024-11-06T17:38:26.716054

Use the JOINKEYS statement to enable join feature processing and to identify the fields used to select records for join processing.

The join feature joins records from two input files that are specified on the SORTJNF1 and SORTJNF2 DD statements. By default, when the JOINKEYS fields from m records in SORTJNF1 match the JOINKEYS fields from n records in SORTJNF2, all combinations of the records are joined using the REFORMAT statement, producing m*n records as input to subsequent MFX processing. (This is called an “inner join.”)

See the discussion of the REFORMAT control statement for a description of how a record is constructed from the two records that have been selected as a match.

If the optional JOIN UNPAIRED statement is specified, the unmatched records from the SORTJNF1 and/or SORTJNF2 files will also be REFORMATted and included in the input to MFX without being joined. (Including the unmatched records from SORTJNF1 is called a “left outer join,” including the unmatched records from SORTJNF2 is called a “right outer join,” and including all unmatched records is called a “full outer join.”) Optionally, only these unmatched records will become input to MFX. See the descriptions of the JOIN and REFORMAT statements for further details on their specification.

The input files do not need to be presorted or have the same record type.

Two JOINKEYS control statements are required – one for each of the two files used in the join.

The JOINKEYS control statement cannot be used with MAXSORT, PARASORT, Syncsort PipeSort, SKIPREC, checkpoint, and merge exits (except for E35), and the DB2 Query feature.

JOINKEYS Control Statement Format

The format of the JOINKEYS control statement is illustrated below:
Figure 1. JOINKEYS Control Statement Format

FILE Parameter (Required)

The FILE parameter connects the JOINKEYS control statement with the input file to be read. The specification of F1 connects the JOINKEYS control statement with the SORTJNF1 DD statement. The specification of F2 connects the JOINKEYS control statement with the SORTJNF2 DD statement. FILE cannot be used if either F1 or F2 is used.

For large applications, if one of the two input files has many more duplicate keys for the join than the other input file, that file should be allocated as SORTJNF2 to achieve optimal performance.

The format of the FILE parameter is illustrated in the following figure.
Figure 2. FILE Parameter Format

F1 and F2 Parameters (Required)

The F1=ddname and F2=ddname parameters are used to specify the ddnames of the input files to be read for the JOINKEYS control statement. F1 is used in place of FILE=F1 to connect JOINKEYS to the first input file and change the ddname from SORTJNF1. F2 is used similarly to connect JOINKEYS to te second input file and change the ddname from SORTJNF2. You should use only one of F1 or F2. The FILE parameter cannot be used if either F1 or F2 has been used.

The format of the F1 and F2 parameters is illustrated below
Figure 3. F1 and F2 Parameter Format

FIELDS Parameter (Required)

The FIELDS parameter is required. It describes the fields to be used to match records from the two files, SORTJNF1 and SORTJNF2.

The number of JOINKEYS fields and their sorted order (A or D) must be the same for both files, although their starting positions and lengths need not be the same.

The join files do not need to be presorted on the fields specified on the JOINKEYS statement. By default, MFX will sort the records to the proper sequence before performing the join operation. If one or both of the files are already in the JOINKEYS fields sequence, the SORTED parameter (see below) of the JOINKEYS statement can be specified. If the SORTED parameter can be used, the performance of the application will be improved since the need for MFX to preorder the records prior to join processing will be removed.

The maximum number of JOINKEYS fields is 64.

Each JOINKEYS field may be anywhere within the record through column 32750, the maximum length of a field is 4080 bytes, and the sum of all fields on a JOINKEYS statement cannot exceed 4080 bytes.

Each field specified in the FIELDS parameter is identified by a position (p), length (l), format (f), and order (o).
p

The position value indicates the first byte of the field relative to the beginning of the input record.

l The length value indicates the length of the control field.
f

The format value indicates the data format. For a list of valid formats, refer to the table in the next section, “Valid Formats for JOINKEYS Fields.” If all the fields have the same format, you can specify the format value once by using the FORMAT=f subparameter. If you specify both the individual f values and the FORMAT subparameter, the individual f values will be used for fields where they are specified.

If the format value is omitted, BI (binary) format will be assumed.

o The order value indicates the collating sequence of the field:

A=Ascending order

D=Descending order

Valid Formats for JOINKEYS Fields

The following table lists the valid formats for JOINKEYS fields.

Table 1. Valid Formats and Lengths of JOINKEYS Fields

Data Format

Acceptable FieldLength (Bytes)

AQ

1 to 4080

BI*

1 to 4080

CH

1 to 4080

FI

1 to 256

PD

1 to 255

ZD

1 to 256

Note: *Bit fields are not permitted.

Note that LOCALE will not be used with CH fields.

Field-to-Field Comparisons

The formats of the JOINKEYS fields for the SORTJNF1 file must be compatible with the corresponding fields for the SORTJNF2 file.

The following table shows the permissible types of format comparisons.

Table 2. Permissible Field-to-Field Comparisons for JOINKEYS Formats

 

AQ

BI

CH

FI

PD

ZD

AQ

X

 

 

 

 

 

BI

 

X

X

 

 

 

CH

 

X

X

 

 

 

FI

 

 

 

X

 

 

PD

 

 

 

 

X

X

ZD

 

 

 

 

X

X  

Padding of Compared Fields of Unequal Lengths

When two fields of unequal lengths are compared, the shorter field is padded to the length of the longer field. Padding takes place as follows:
  • The padding characters are blanks when the shorter field is in CH or AQ format; otherwise, they are zeros of the shorter field’s own format. For negative FI fields, the padding character is X‘FF’.

  • Padding is on the right if the shorter field is in BI, CH or AQ format. Padding is on the left for FI, PD and ZD formats.

SORTED Parameter (Optional)

By default, MFX will presume that the records in the file are not presequenced per the JOINKEYS fields specified. If the records are already collated in the proper sequence, the SORTED parameter can be specified to improve the application's performance. Since LOCALE is not used for CH JOINKEYS fields, do not specify SORTED if the files were previously sorted with LOCALE.

MFX will sequence check each input file according to its JOINKEYS fields. If the SORTED parameter of the JOINKEYS statement was specified to indicate that the file was presorted and the sequence check fails, MFX will issue a critical error message containing the file number. The record number within the file will also be in the error message text whenever the INCLUDE/OMIT parameter of the JOINKEYS statement was not specified.

NOSEQCK Parameter (Optional)

The NOSEQCK parameter may be used when the SORTED parameter has been specified. NOSEQCK instructs MFX to bypass the sequence check that MFX performs for the sorted input file. NOSEQCK should only be used when you are certain that the input file connected to the JOINKEYS statement has already been sorted in the same collating sequence as specified in the JOINKEYS FIELDS parameter, otherwise your output may be incorrect. NOSEQCK may slightly improve the performance of your JOINKEYS application. NOSEQCK is ignored if SORTED has not been specified.

INCLUDE/OMIT Parameter (Optional)

Specify the INCLUDE or OMIT parameter to indicate which records are to be included or omitted from the SORTJNFn file specified on the JOINKEYS statement. The INCLUDE/OMIT processing occurs prior to the JOINKEYS field matching process.

The format for the INCLUDE/OMIT parameter is illustrated below:
Figure 4. INCLUDE/OMIT Parameter Format

See INCLUDE/OMIT Control Statement for the detailed format of a comparison. The FORMAT=f parameter, which is permitted for the INCLUDE/OMIT control statement, is not permitted for the INCLUDE/OMIT parameter. Field formats must be specified on a field-by-field basis. 

TASKID Parameter (Optional)

The TASKID=xx parameter is used to change the first two bytes of the ddnames for the dynamically allocated sortwork data sets used to sort the JOINKEYS input file. This parameter should be used when invoking MFX from a program and attaching multiple join applications that will run concurrently.

TYPE Parameter (Optional)

The TYPE parameter can be used to indicate the record format. TYPE=F indicates fixed-length records; TYPE=V indicates variable-length records.

TYPE should be provided if the input file being specified is VSAM. If TYPE is not provided, TYPE=F will be assumed if the SORTJNFn file is VSAM.

Note: If the TYPE specification differs from the RECFM DCB parameter for the SORTJNFn DD statement, the latter takes precedence.

For more information, see Joining Records from Multiple Files.

STOPAFT Parameter (Optional)

The STOPAFT parameter limits the number of records processed from the SORTJNFn file specified. This can be useful when testing a new join application. You can sample a subset of one or both input files and view your output without having to sort both input files in their entirety and possibly generate a very large number of joined records.

The variable n specifies the number of records to be sorted or copied from SORTJNF1 or SORTJNF2. These will be the first n records after JOINKEYS INCLUDE/OMIT processing, if specified, has completed.