DFSORT OUTFIL Updating counts and totals in trailer

DFSORT OUTFIL: Creating Reports DFSORT OUTFIL: Converting FB to VB

Advertisements


OUTFIL's IFTRAIL parameter can be used to update count and total values in an existing trailer (last) record to reflect the actual data records in the OUTFIL data set.

IFTRAIL communicates DFSORT to update the trailer record.


Syntax:

OUTFIL FNAMES=DDNAMEn,  IFTRAIL=(TRLID=(starting position, length, format, Character/String),
TRLUPD=(…))

Name Description
DDNAMEnDDNAME is eight character’s name that representing the actual dataset in JCL.
TRLID=(logexp) identifies the trailer record using the same type of logical expression used for INCLUDE.
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.

HD=YES indicates the first record is a header record.

If theinput data set has a header, HD=YES need to use to avoid treating the headerrecord as a data record.

TRLID=(logexp) identifies the trailer record as having a 'T' in position 1.

Theidentified trailer record is treated as the last record; it is not treated as a datarecord.

TRLUPD indicates the counts and totals to be updated.


Example: -

Separate the depart level files with min,max, avg marks statistics for each department.


Input File: MTHUSER.SORT.INPUT01 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
H 2017/01/17                                                                    
DTL 1     student1           dept1      560                                 
DTL 2     student2           dept3      510                                 
DTL 3     student3           dept2      520                                 
DTL 4     student4           dept1      540                                 
DTL 5     student5           dept2      500                                 
DTL 6     student6           dept3      550                                 
DTL 7     student7           dept3      510                                 
DTL 8     student8           dept1      530                                 
DTL 9     student9           dept2      520                                 
DTL10     student10          dept2      505                                 
T 00010                                                                         
******************************** Bottom of Data ********************************

Job:

000100 //Jobcard 
000400 //*                                                                     
000500 //**********************************************************************
000600 //*                                                                     
001100 //STEP01   EXEC PGM=SORT                                               
001300 //SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                   
001801 //OUTPUT1  DD DSN=MTHUSER.SORT.OUTPT01,                           
001802 //             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                    
001803 //             DISP=(NEW,CATLG,DELETE)                                 
001804 //OUTPUT2  DD DSN=MTHUSER.SORT.OUTPT02,                           
001805 //             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                    
001806 //             DISP=(NEW,CATLG,DELETE)                                 
001807 //OUTPUT3  DD DSN=MTHUSER.SORT.OUTPT03,                           
001808 //             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                    
001809 //             DISP=(NEW,CATLG,DELETE)                                 
001810 //SYSOUT   DD SYSOUT=*                                                 
002410 //SYSIN    DD *                                                        
002411      OPTION COPY                                                       
002420                                                                        
002421      OUTFIL FNAMES=OUTPUT1,INCLUDE=(30,5,CH,EQ,C'dept1'),              
002430             IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'),                    
002431        TRLUPD=(6:COUNT=(M11,LENGTH=4),14:TOT=(41,3,ZD,TO=ZD,LENGTH=6)))
002440                                                                         
002450      OUTFIL FNAMES=OUTPUT2,INCLUDE=(30,5,CH,EQ,C'dept2'),               
002460             IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'),                     
002470        TRLUPD=(6:COUNT=(M11,LENGTH=4),14:TOT=(41,3,ZD,TO=ZD,LENGTH=6))) 
002480                                                                         
002490      OUTFIL FNAMES=OUTPUT3,INCLUDE=(30,5,CH,EQ,C'dept3'),               
002500             IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'),                     
002600        TRLUPD=(6:COUNT=(M11,LENGTH=4),14:TOT=(41,3,ZD,TO=ZD,LENGTH=6))) 
002700                                                                         
002800  /*                                                                      
****** **************************** Bottom of Data ****************************

Output File: MTHUSER.SORT.OUTPT01 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
H 2017/01/17                                                                    
DTL 1     student1           dept1      560                                     
DTL 4     student4           dept1      540                                     
DTL 8     student8           dept1      530                                     
T 0000003    001630                                                             
******************************** Bottom of Data ******************************** 

File: MTHUSER.SORT.OUTPT02 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
H 2017/01/17                                                                    
DTL 3     student3           dept2      520                                     
DTL 5     student5           dept2      500                                     
DTL 9     student9           dept2      520                                     
DTL10     student10          dept2      505                                     
T 0000004    002045                                                             
******************************** Bottom of Data ********************************

File: MTHUSER.SORT.OUTPT03 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
H 2017/01/17                                                                    
DTL 2     student2           dept3      510                                     
DTL 6     student6           dept3      550                                     
DTL 7     student7           dept3      510                                     
T 0000003    001570                                                             
******************************** Bottom of Data ********************************

Explaining Solution:

  1. OUTFIL FNAMES=OUTPUT1,INCLUDE=(30,5,CH,EQ,C'dept1') - All the records marching with “dept1” from the 30th position of length 5 will be copied to output1 file.

  2. OUTFIL FNAMES=OUTPUT1,..,IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T') - IFTRAIL tells to DFSORT that update the tailor record in output1 file.

  3. OUTFIL FNAMES=OUTPUT1,.., TRLUPD=(6:COUNT=(M11,LENGTH=4),14:TOT=(41,3,ZD,TO=ZD,LENGTH=6)) - Updates the trailer record in the output1 file.

  4. OUTFIL FNAMES=OUTPUT2,INCLUDE=(30,5,CH,EQ,C'dept2') - All the records marching with “dept2” from the 30th position of length 5 will be copied to output2 file.

  5. OUTFIL FNAMES=OUTPUT2,..,IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T') - IFTRAIL tells to DFSORT that update the tailor record in output2 file.

  6. OUTFIL FNAMES=OUTPUT2,.., TRLUPD=(6:COUNT=(M11,LENGTH=4),14:TOT=(41,3,ZD,TO=ZD,LENGTH=6)) - Updates the trailer record in the output2 file.

  7. OUTFIL FNAMES=OUTPUT3,INCLUDE=(30,5,CH,EQ,C'dept1') - All the records marching with “dept3” from the 30th position of length 5 will be copied to output3 file.

  8. OUTFIL FNAMES=OUTPUT3,..,IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T') - IFTRAIL tells to DFSORT that update the tailor record in output3 file.

  9. OUTFIL FNAMES=OUTPUT3,.., TRLUPD=(6:COUNT=(M11,LENGTH=4),14:TOT=(41,3,ZD,TO=ZD,LENGTH=6)) - Updates the trailer record in the output3 file.

DFSORT OUTFIL: Creating Reports DFSORT OUTFIL: Converting FB to VB

Advertisements