z/OS DFSORT Application Programming Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 30

z/OS DFSORT Application Programming Guide
SC23-6878-00

  OPTION COPY                                       
  OUTFIL FNAMES=OUT1,                               
   INCLUDE=(3,4,CH,EQ,C'key1'),                     
   IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'),          
    TRLUPD=(6:COUNT=(M11,LENGTH=4),                 
           14:TOT=(10,4,ZD,TO=ZD,LENGTH=6)))        
  OUTFIL FNAMES=OUT2,                               
   INCLUDE=(3,4,CH,EQ,C'key2'),                     
   IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'),          
    TRLUPD=(6:COUNT=(M11,LENGTH=4),                 
           14:TOT=(10,4,ZD,TO=ZD,LENGTH=6)))

This example illustrates how you can split an input file with a header, and a trailer containing a count and total for the input data records, into two output files each of which has the header and a trailer with accurate count and total for the included data records.

The input data set has RECFM=FB and LRECL=80 with these input records:
H 2010/07/06
D key1   0100
D key2   0200
D key2   0118
D key1   0150
D key1   0025
D key2   1000
D key2   0310
T X  0007 QR 001903  D52-007-321-7526

The first record is a header record with a date. The records with D in position 1 are data records; they have key1 or key2 in positions 3-6 and an amount field in positions 10-13.

The trailer record is identified by a 'T' in position 1. 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. In addition, there are other static fields in the trailer record that must not be changed. Note that IFTRAIL with HD=YES does not process the header or trailer records as data records, so they are not included in the count or total.

The first OUTFIL statement writes the header record, data records with key1, and trailer record, in the OUT1 data set. The IFTRAIL operand is used to identify the trailer (TRLID), indicate the first record is a header (HD=YES), and update the count and total in the trailer (TRLUPD) to reflect the input data records included in this output data set.

OUT1 will have these records:
H 2010/07/06
D key1   0100
D key1   0150
D key1   0025
T X  0003 QR 000275  D52-007-321-7526

The second OUTFIL statement writes the header record, data records with key2, and trailer record, in the OUT2 data set. The IFTRAIL operand is used to identify the trailer (TRLID), indicate the first record is a header (HD=YES), and update the count and total in the trailer (TRLUPD) to reflect the input data records included in this output data set. Note that IFTRAIL with HD=YES does not process the header or trailer records as data records, so they are not included in the count or total.

OUT2 will have these records:
H 2010/07/06                                    
D key2   0200                                   
D key2   0118                                   
D key2   1000                                   
D key2   0310                                   
T X  0004 QR 001628  D52-007-321-7526

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014