Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Example 26 z/OS DFSORT Application Programming Guide SC23-6878-00 |
|
This example illustrates how you can create a sorted report from FB input records with keyword values that can occur in any order or not occur at all. The 80-byte input records might look like this:
Note that each record has up to four variable fields each identified by a specific keyword (First, Middle, Last, Wife). In each record, the fields can be in any order, do not start and end in the same position and can have different lengths. We want to sort the records by last name, first name and middle
name, and create a report with fixed headings and values for the first
name, middle name, last name and wife's name that looks like this:
In order to extract and sort variable fields like these, we use a separate IFTHEN PARSE clause for each keyword. This allows us to find a particular keyword anywhere in the record or ignore it if it is not in the record. If we used PARSE instead of IFTHEN PARSE, a missing keyword would cause any keywords that followed to be ignored. But because each IFTHEN PARSE starts scanning at position 1 by default, we can look for each keyword independently of the others. If a keyword is missing, the parsed field is set to all blanks (for example, %2 and %4 are set to blanks for the James Buchanan record). We use %1 to create a 10-byte fixed parsed field into which we extract the first name. We use %2 to create a 10-byte fixed parsed field into which we extract the middle name. We use %3 to create a 10-byte fixed parsed field into which we extract the last name. We use %4 to create a 10-byte fixed parsed field into which we extract the wife's name. We use BUILD to reformat the records to contain the fixed parsed fields. Then we SORT on the fixed parsed fields. Finally, we use OUTFIL to create the headings. |
Copyright IBM Corporation 1990, 2014
|