Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Example 2 - Combine complete records from four files z/OS DFSORT Application Programming Guide SC23-6878-00 |
|
This example shows how you can use the WITHEACH operand to splice complete records from four different data sets together.
Because the data sets do not have a common key, we add sequence
numbers to the records from each data set and use the sequence numbers
as the ON field for SPLICE. Using this technique, we can splice together
the 300-byte records from FILE1, the 400-byte records from FILE2,
the 150-byte records from FILE3 and the 20-byte records from FILE4,
to produce 870-byte records in ALLRCDS. Conceptually, the 870-byte
records in ALLRCDS would look like this:
The base records originate from the FILE1 data set and the overlay records originate from the FILE2, FILE3 and FILE4 data sets. Here is what the various ICETOOL operators do in this job: The first COPY operator creates reformatted records in the T1 data set with the FILE1 records in positions 1-300, blanks in all other positions up to 870, and a sequence number in positions 871-878. The sequence number will be 1 for the first FILE1 record, 2 for the second FILE1 record, and so on. The second COPY operator creates reformatted records in the T1 data set with the FILE2 records in positions 301-700, blanks in all other positions up to 870, and a sequence number in positions 871-878. The sequence number will be 1 for the first FILE2 record, 2 for the second FILE2 record, and so on. The third COPY operator creates reformatted records in the T1 data set with the FILE3 records in positions 701-850, blanks in all other positions up to 870, and a sequence number in positions 871-878. The sequence number will be 1 for the first FILE3 record, 2 for the second FILE3 record, and so on. The fourth COPY operator creates reformatted records in the T1 data set with the FILE4 records in positions 851-870, blanks in all other positions up to 850, and a sequence number in positions 871-878. The sequence number will be 1 for the first FILE4 record, 2 for the second FILE4 record, and so on. Note that MOD is used for the T1 data set, so the reformatted records from FILE1, FILE2, FILE3 and FILE4 will be output in that order in T1, ensuring that they are sorted and spliced in that order. The SPLICE operator sorts the records from T1 using the sequence number as the ON field. With WITHEACH, the reformatted FILE1 records are treated as the base records, and the reformatted FILE2, FILE3 and FILE4 records are treated as the overlay records; each WITH field is associated with an overlay record in turn. So the first WITH field specifies the bytes to be used from the second duplicate (FILE2 record), the second WITH field specifies the bytes to be used from the third duplicate (FILE3 record) and the third WITH field specifies the bytes to be used from the fourth duplicate (FILE4 record). SPLICE matches each base and overlay record by their sequence numbers, and creates a new combined 878-byte record. The OUTFIL statement in CTL5CNTL is used to remove the sequence number so that the 870-byte spliced record is written to the ALLRCDS data set. |
Copyright IBM Corporation 1990, 2014
|