Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Example 4 - Create a matrix of values z/OS DFSORT Application Programming Guide SC23-6878-00 |
|
This example shows how you can use the WITHANY operand to create a matrix of values. We combine multiple rows for different types of data with a common key into a single row of data for that key, even if some rows are missing.
The input records look like this:
We have a key (for example, '001') in positions 1-3, a record type (1, 2 or 3) in position 5 and a numeric value in positions 8-10. We want to set up a single row for each key with the values for the three record types and blanks for missing record types. Before we SPLICE the records, we use the INREC IFTHEN clauses to
put the values from the type 1 records in positions 5-7, the values
from the type 2 records in positions 9-11 and the values from the
type 3 records in positions 13-15. The reformatted INREC records
look like this:
We use SPLICE with WITHANY and appropriate WITH fields to create one combined record for each key with the values for the record types. We use KEEPNODUPS to keep records for keys with only one value (for example, '004'). The OUT records are 15 bytes long and look like this:
Note that if we used WITHEACH instead of WITHANY, the output would
not be what we wanted since record types are missing for some keys
(for example, type 1 is missing for key 002), and record types are
out of order for some keys (for example, we have type 3, type 2 and
type 1 in that order for key 001). With WITHEACH, the OUT records
would look like this:
|
Copyright IBM Corporation 1990, 2014
|