z/OS DFSORT Application Programming Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


JOINKEYS statements

z/OS DFSORT Application Programming Guide
SC23-6878-00

Read syntax diagramSkip visual syntax diagram
                                             .-,-----.        
                                             V       |        
>>-JOINKEYS--+-FILE=F1---+--,--FIELDS=----(----p,m,s-+--)------->
             +-FILES=F1--+                                    
             +-F1=ddname-+                                    
             +-FILE=F2---+                                    
             +-FILES=F2--+                                    
             '-F2=ddname-'                                    

>--+--------------------------------------------+--------------><
   | .-,--------------------------------------. |   
   | V                                        | |   
   '---+-SORTED--+------------+-------------+-+-'   
       |         '-,--NOSEQCK-'             |       
       +-TYPE=--+-F-+-----------------------+       
       |        '-V-'                       |       
       +-STOPAFT=n--------------------------+       
       +-TASKID=id--------------------------+       
       +-INCLUDE=--+-(logical expression)-+-+       
       |           +-ALL------------------+ |       
       |           '-NONE-----------------' |       
       '-OMIT=--+-(logical expression)-+----'       
                +-ALL------------------+            
                '-NONE-----------------'            

Two JOINKEYS statements are required for a JOINKEYS application; one for the F1 file and the other for the F2 file:
  • FILE=F1 or F1=ddname must be used to indicate that the JOINKEYS statement applies to the F1 input file. FILE=F1 associates the F1 file with a ddname of SORTJNF1. You can use a different ddname for the F1 file by specifying F1=ddname. For simplicity, we will use SORTJNF1 when referring to the ddname for the F1 file.
  • FILE=F2 or F2=ddname must be used to indicate that the JOINKEYS statement applies to the F2 input file. FILE=F2 associates the F2 file with a ddname of SORTJNF2. You can use a different ddname for the F2 file by specifying F2=ddname. For simplicity, we will use SORTJNF2 when referring to the ddname for the F2 file.
FILE=F1, FILES=F1 or F1=ddname
Read syntax diagramSkip visual syntax diagram
>>-+-FILE=F1---+-----------------------------------------------><
   +-FILES=F1--+   
   '-F1=ddname-'   

Must be used for the JOINKEYS statement associated with the F1 file. FILE=F1 (or FILES=F1) specifies a ddname of SORTJNF1 for the F1 file. F1=ddname can be used to specify any valid ddname for the F1 file. Do not use the same ddname for the F1 file and the F2 file.

When FILE=F1, FILES=F1 or F1=ddname is specified, the other operands of the JOINKEYS statement apply to the F1 file.

FILE=F2, FILES=F2 or F2=ddname
Read syntax diagramSkip visual syntax diagram
>>-+-FILE=F2---+-----------------------------------------------><
   +-FILES=F2--+   
   '-F2=ddname-'   

Must be used for the JOINKEYS statement associated with the F2 file. FILE=F2 (or FILES=F2) specifies a ddname of SORTJNF2 for the F2 file. F2=ddname can be used to specify any valid ddname for the F2 file. Do not use the same ddname for the F1 file and the F2 file.

When FILE=F2, FILES=F2 or F2=ddname is specified, the other operands of the JOINKEYS statement apply to the F2 file.

FIELDS
Read syntax diagramSkip visual syntax diagram
                 .-,-----.        
                 V       |        
>>-FIELDS=----(----p,m,s-+--)----------------------------------><

Must be specified to indicate the starting position, length and order (ascending or descending) of the keys in the input file. The keys will be treated as binary, so they must be "normalized". For example, if the keys are actually zoned decimal, they must have all C and D signs, or all F and D signs. You can use an INREC statement in JNF1CNTL and/or JNF2CNTL to normalize the keys for the F1 file and/or F2 file, respectively, if appropriate.

Each pair of keys for the F1 and F2 files must match with respect to length and order, but can start in different positions. For example, if the first key for the F1 file is 5 bytes ascending and the second key for the F1 file is 3 bytes descending, the first key for the F2 file must be 5 bytes ascending and the second key for the F2 file must be 3 bytes descending.

If a variable-length record is too short to contain a key you specify, the short key value will be compared using binary zeros for the missing bytes.

p
specifies the starting position of the key. The first data byte of a fixed-length record is in position 1. The first data byte of a variable-length record is in position 5 after the 4-byte RDW. p can be 1 to 32752 but all fields must be completely contained within the first 32752 bytes of the record.
m
specifies the length of the key. The total length of all keys must not exceed 4080 bytes. All fields must be completely contained within the first 32752 bytes of the record.

The length for each pair of F1 and F2 keys must match.

s
specifies the order of the key. Use A for ascending or D for descending.

The order for each pair of F1 and F2 keys must match.

For example, if you specify:
  JOINKEYS F1=IN1,FIELDS=(22,3,A,55,9,D)
  JOINKEYS F2=IN2,FIELDS=(15,3,A,1,9,D)

File F1 is processed using the ddname IN1, the ascending key in positions 22-24 and the descending key in positions 55-63. File F2 is processed using the ddname IN2, the ascending key in positions 15-17 and the descending key in positions 1-9.

SORTED
Read syntax diagramSkip visual syntax diagram
>>-SORTED------------------------------------------------------><

By default, DFSORT will sort the input file by the specified keys. If the records of the input file are already in sorted order by the specified keys, you can use the SORTED operand to tell DFSORT to copy the records rather than sort them. This can improve performance. DFSORT will terminate if the copied records are not in the order specified by the keys unless you specify the NOSEQCK operand.

For example, if you specify:
  JOINKEYS FILE=F1,FIELDS=(22,3,A),SORTED
  JOINKEYS FILE=F2,FIELDS=(15,3,A)

File F1 is copied using the ddname SORTJNF1 and the ascending key in positions 22-24. The SORTJNF1 records will be checked for the correct key order. File F2 is sorted using the ddname SORTJNF2 and the ascending key in positions 15-17.

If you use the SORTED operand, statements and options only available for a sort application, such as SUM, will be ignored for the subtask that copies the input file.

NOSEQCK
Read syntax diagramSkip visual syntax diagram
>>-NOSEQCK-----------------------------------------------------><

If you specify the SORTED operand and know that the records of the input file are already in sorted order by the specified keys, you can use the NOSEQCK operand to tell DFSORT not to check the order of the records. This can improve performance.

For example, if you specify:
  JOINKEYS FILE=F1,FIELDS=(22,3,A),SORTED,NOSEQCK
  JOINKEYS FILE=F2,FIELDS=(15,3,A),SORTED

File F1 is copied using the ddname SORTJNF1 and the ascending key in positions 22-24. The SORTJNF1 records will be not be checked for the correct key order. File F2 is copied using the ddname SORTJNF2 and the ascending key in positions 15-17. The SORTJNF2 records will be checked for the correct key order.

If the records are not actually in order by the specified keys and you use NOSEQCK, the output may be incorrect.

The NOSEQCK operand is ignored if the SORTED operand is not specified.

TYPE
Read syntax diagramSkip visual syntax diagram
>>-TYPE=--+-F-+------------------------------------------------><
          '-V-'   

TYPE=V can be used to tell DFSORT to use variable-length processing for a VSAM input file. TYPE=F (the default) can be used to tell DFSORT to use fixed-length processing for a VSAM input file.

For example, if you specify:
  JOINKEYS F1=VSAM1,FIELDS=(22,3,A),TYPE=V
  JOINKEYS F2=VSAM2,FIELDS=(15,3,A),TYPE=F

VSAM file F1 is sorted as variable-length records using the ddname VSAM1 and the ascending key in positions 22-24. (Remember that for TYPE=V VSAM processing, DFSORT adds an RDW in positions 1-4 which you must account for when specifying the starting position.) VSAM file F2 is sorted as fixed-length records using the ddname VSAM2 and the ascending key in positions 15-17. (Remember that for TYPE=F VSAM processing, DFSORT does not add an RDW.)

STOPAFT
Read syntax diagramSkip visual syntax diagram
>>-STOPAFT=n---------------------------------------------------><

Can be used to specify the maximum number of records (n) you want the subtask for the input file to accept for sorting or copying (accepted means read from the input file and not deleted by INCLUDE or OMIT).

n
can be up to 28 digits with up to 15 significant digits.
For example, if you specify:
  JOINKEYS FILE=F1,STOPAFT=5,FIELDS=(32,4,A)
  JOINKEYS FILE=F2,STOPAFT=10,FIELDS=(32,4,A)

The first 5 input records from SORTJNF1 and the first 10 input records from SORTJNF2 will be processed.

You can use STOPAFT=n on the OPTION statement in JNF1CNTL (for the F1 file) or JNF2CNTL (for the F2 file) instead of specifying STOPAFT=n on the JOINKEYS statement.

For example, instead of the STOPAFT operands in the JOINKEYS statements shown previously, you could specify:
//SYSIN DD *
  JOINKEYS FILE=F1,FIELDS=(32,4,A)
  JOINKEYS FILE=F2,FIELDS=(32,4,A)
  ...
//JNF1CNTL DD *
  OPTION STOPAFT=5
//JNF2CNTL DD *
  OPTION STOPAFT=10
TASKID
Read syntax diagramSkip visual syntax diagram
>>-TASKID=id---------------------------------------------------><

By default, DFSORT uses the following ddnames for the subtasks:
  • JNF1JMSG for the subtask1 (F1 file) message data set.
  • JNF1CNTL for the subtask1 (F1 file) control data set.
  • JNF1WKdd for the subtask1 (F1 file) work data sets.
  • JNF2JMSG for the subtask2 (F2 file) message data set.
  • JNF2CNTL for the subtask2 (F2 file) control data set.
  • JNF2WKdd for the subtask2 (F2 file) work data sets.

The TASKID=id operand can be used to change the first two characters from JN to the specified id characters. The same id can be used for the F1 and F2 ddnames, or a different id can be used for each.

For example, if you specify:
  JOINKEYS F1=IN1,FIELDS=(1,10,A),TASKID=C1
  JOINKEYS F2=IN2,FIELDS=(22,10,A),TASKID=C1

C1F1JMSG, C1F1CNTL and C1F1WKdd will be used for subtask1 (F1 file). C1F2JMSG, C1F2CNTL and C1F2WKdd will be used for subtask2 (F2 file).

If you specify:
  JOINKEYS F1=IN1,FIELDS=(1,10,A),TASKID=I1
  JOINKEYS F2=IN2,FIELDS=(22,10,A),TASKID=I2

I1F1JMSG, I1F1CNTL and I1F1WKdd will be used for subtask1 (F1 file). I2F2JMSG, I2F2CNTL and I2F2WKdd will be used for subtask2 (F2 file).

The TASKID=id operand can be useful when you are doing multiple JOINKEYS applications and want to separate the messages for each application and/or specify different control statements or work data sets for different subtasks.

INCLUDE or OMIT
Read syntax diagramSkip visual syntax diagram
>>-+-INCLUDE-+--+-(logical expression)-+-----------------------><
   '-OMIT----'  +-ALL------------------+   
                '-NONE-----------------'   

Can be used to specify criteria for the records you want the subtask for the input file to include or omit for sorting or copying. You can use the same logical expressions, ALL or NONE in the same way as for the INCLUDE or OMIT operand of the OUTFIL statement. See OUTFIL control statements for details.

For example, if you specify:
  JOINKEYS FILE=F1,FIELDS=(35,8,A),
     OMIT=(5,4,CH,EQ,C'ABCD')
  JOINKEYS FILE=F2,FIELDS=(37,8,A),
     INCLUDE=(1,20,SS,EQ,C'NO')

Only records without 'ABCD' in positions 5-8 will be processed from file F1. Only records with 'NO' somewhere in positions 1-20 will be processed from file F2.

Although the INCLUDE and OMIT operands are available on the JOINKEYS statement, it is recommended that you specify an INCLUDE or OMIT statement in JNF1CNTL or JNF2CNTL instead for ease of use.

For example, instead of the OMIT and INCLUDE operands in the JOINKEYS statements shown previously, you could specify:
//SYSIN DD *
  JOINKEYS FILE=F1,FIELDS=(35,8,A)
  JOINKEYS FILE=F2,FIELDS=(37,8,A)
  ...
//JNF1CNTL DD *
  OMIT COND=(5,4,CH,EQ,C'ABCD')
//JNF2CNTL DD *
  INCLUDE COND=(1,20,SS,EQ,C'NO')

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014