Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Example 4 - Unpaired F2 records z/OS DFSORT Application Programming Guide SC23-6878-00 |
|
This example illustrates how you can select only unpaired records from one of two files. In this case, we will select the F2 records that do not have a match in F1 on the specified keys (for example, key1=Molly and key2=2100). We will also omit certain records from each input file and handle unnormalized keys. Input file1 has RECFM=FB and LRECL=15. It contains the following
records:
Input file2 has RECFM=VB and LRECL=35. It contains the following
records:
The output file will have RECFM=VB and LRECL=35. F1 records with
99999 in positions 10-14 and F2 records with 99999 in positions 14-18
will be removed before join processing. The output file will contain
unpaired F2 records (that is, records from F2 that do not have a match
in F1 for the specified keys) as follows:
The first JOINKEYS statement defines the ddname and keys for the F1 file. F1=IN1 tells DFSORT that the ddname for the F1 file is IN1. The control statements in JNF1CNTL will be used to process the
F1 file before it is sorted. The OMIT statement removes records that
have 99999 in positions 10-14. We want to use the numeric field as
our key. However, the numeric field is unnormalized since it is left
aligned instead of right aligned, so sorting it as a binary key will
not work. To handle this, we use the INREC statement to reformat
the numeric field as ZD values in positions 9-13 (positive ZD values
with the same sign can be sorted as binary). For example, the first
reformatted FB record will look like this:
Since we don't need the F1 records for output, we don't need to keep the original left aligned numeric value. FIELDS=(1,8,A,9,5,D) in the JOINKEYS statement (referring to the reformatted INREC positions) tells DFSORT that the first key is in positions 1-8 ascending and the second key is in positions 9-13 descending. The second JOINKEYS statement defines the ddname and keys for the F2 file. F2=IN2 tells DFSORT that the ddname for the F2 file is IN2. The control statements in JNF2CNTL will be used to process the
F2 file before it is sorted. The OMIT statement removes records that
have 99999 in positions 14-18. Again, we need a ZD version of the
left aligned numeric value to use for the binary key. But in this
case, since we want the original F2 records for output, we need to
keep the original numeric value as well. Using the INREC statement,
we add the ZD value at positions 5-9 between the RDW and the first
data field. That shifts the original data to start at position 10.
For example, the first reformatted VB record will look like this:
In this case, since the input is a VB file, we specify the RDW (1,4), then the converted field, and then the rest of the record (5 without a length) in the INREC statement. FIELDS=(10,8,A,5,5,D) in the JOINKEYS statement (referring to the reformatted INREC positions) tells DFSORT that the first key is in positions 10-17 ascending and the second key is in positions 5-9 descending. Note that since IN2 is a VB file, all of its starting positions must take the RDW in positions 1-4 into account. The JOIN statement tells DFSORT that the joined records should be the F2 records that do not have a match in F1 on the specified keys. The REFORMAT statement defines the fields to be extracted for the
joined records in the order in which they are to appear. We need
the RDW (1,4) and the original data which starts in position 10 of
the reformatted F2 records. So we use FIELDS=(F2:1,4,10). Since
the last field (10) is a position without a length, it tells DFSORT
to create VB records. The joined records are created as follows from
the reformatted F2 records:
Conceptually, JOINKEYS application processing proceeds as follows:
|
Copyright IBM Corporation 1990, 2014
|