Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Updating counts and totals in trailer with OUTFIL z/OS DFSORT: Getting Started SC23-6880-00 |
|||
You can use OUTFIL's IFTRAIL parameter to update count and total values in an existing trailer (last) record to reflect the actual data records in the OUTFIL data set. Suppose another process deleted 3 records from a data set that
originally contained 7 records, but did not update the counts and
totals in the trailer record. The modified data set looks like this:
The data records are identified by a '1' and the trailer record is identified by a '9'. Note that the count of data records is 7 even though there are now only 4 data records, and the totals are also incorrect. You can use the following OUTFIL statement to update the trailer
record with the correct count and totals:
IFTRAIL tells DFSORT to update the trailer record. TRLID=(logexp) identifies the trailer record using the same type of logical expression you can use for INCLUDE. In this case, we identify the trailer record as having a '9' in position 1. The identified trailer record is treated as the last record; it is not treated as a data record. TRLUPD indicates the fields in the data records to be used to update counts and totals. c:, COUNT=, COUNT+n=, COUNT-n=, TOT= and TOTAL= can be used in TRLUPD in the same way they are used in TRAILER1. The output data set will contain these data records and a trailer
record updated with the correct count and totals:
You can also use IFTRAIL to update counts and totals as you modify a data set, such as when you use two OUTFIL statements to split a data set. Suppose your input data set has a header, data and trailer records
like this:
The header record is identified by an 'H', the data records are identified by a 'D' and the trailer record is identified by a 'T'. In the trailer record, positions 6-9 contain a count (0007) of the data records, and positions 14-19 contain a total (001903) for the amount fields in the data records. You can use the following OUTFIL statements to split the data records
by key (key1 and key2) into two output data sets each of which has
the header and trailer with accurate count and total for the included
data records.
IFTRAIL tells DFSORT to update the trailer record. INCLUDE includes the records with key1 (for OUT1) or key2 (for OUT2). HD=YES indicates the first record is a header record. The header record will be output without change and its fields will not be used for the count or total. If the input data set has a header, you must use HD=YES to avoid treating the header record as a data record. TRLID=(logexp) identifies the trailer record as having a 'T' in position 1. The identified trailer record is treated as the last record; it is not treated as a data record. TRLUPD indicates the counts and totals to be updated. The results produced for OUT1 are:
The trailer record has a count (0003) and total (000275) for the three included data records. The results produced for OUT2 are:
The trailer record has a count (0004) and total (001628) for the four included data records. For complete details on using IFTRAIL, see z/OS DFSORT Application Programming Guide.
|
Copyright IBM Corporation 1990, 2014
|