OUTFIL: Creating Reports


OUTFIL can be used to create one or more detailed reports using BUILD, OUTREC, OVERLAY, FINDREP, IFTHEN, HEADERn, TRAILERn, SECTIONS, LINES, NODETAIL, BLKCCH1, BLKCCH2, BLKCCT1, and REMOVECC.

The below ones can include in reports -

  1. A cover sheet (report header)
  2. A header at the top of each page (page header)
  3. A trailer at the bottom of each page (page trailer)
  4. A header at the start of each section (section header)
  5. A trailer at the end of each section (section trailer)
  6. A summary sheet (report trailer)

Reports may contain a variety of elements you specify such as current date,current time, edited or converted page numbers, character strings, and blank lines.

Headers -


OUTFIL used to create the reports with headers. OUTFIL can add headers to the report during the processing.

Syntax -


OPTION COPY
OUTFIL FNAMES=DDNAMEn, 
	HEADER2=(…….),
	OUTREC=(….)
DDNAMEnDDNAME is eight character’s name that representing the actual dataset in JCL.
HEADER2Specifies the header of the report.

Notes -


  • All of the elements in the HEADER2 parameter should be in sync with the OUTREC statement. Start character strings in headers (HEADERn parameters) or trailers (TRAILERn parameters) should not start with C.
  • If n/ is used at the start or end of a header or trailer, n blank lines are printed. If n/ is used in the middle of a header or trailer, n-1 blanks lines are printed.
  • OUTFIL's HEADER1 parameter is very similar to the HEADER2 parameter, except that it produces a report heading on a separate page before the first page of data. i.e., HEADER1 parameter is used to produce the coversheet information.
  • If to start the page heading on the same page as the report heading, OUTFIL's BLKCCH2 parameter can be used.
  • OUTFIL's BLKCCH2 parameter informs DFSORT to replace the '1' in the first line of the first page heading with a blank, thus avoiding the page eject.
  • OUTFIL's BLKCCH1 parameter can be used to inform DFSORT to replace the '1' in the first line of the report heading with a blank, thus avoiding the page eject for the report heading.

Example -


Scenario - Create the report with headers like below -

********************************* Top of Data **********************************
                   Student Details  Printed on 01/13/2017 AT 05:52:27           
                                                                                
              Class X Students details Page     1    on  01-13-2017             
                                                                                
Std num   Std name           Department     Total marks                         
-------   --------           ----------     -----------                         

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001     student1           dept1          560                                 
00003     student3           dept2          520                                 
00004     student4           dept1          540                                 
00005     student5           dept2          500                                 
00002     student2           dept3          510                                 
00006     student6           dept3          550                                 
00008     student8           dept1          530                                 
00007     student7           dept3          510                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Jobcard 
//*                                                                     
//**********************************************************************
//*                                                                     
//STEP01   EXEC PGM=SORT                                                
//SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                    
//OUTPUT1  DD DSN=MTHUSER.SORT.OUTPT01,                            
//             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
//             DISP=(NEW,CATLG,DELETE)                                  
//SYSOUT   DD SYSOUT=*                                                  
//SYSIN    DD *                                                         
     SORT FIELDS=(1,5,ZD,A)                                             
     OUTFIL FNAMES=OUTPUT1,LINES=9,BLKCCH2,                             
                                                                        
     HEADER1=(20:'Student Details',                                     
              37:'Printed on ',DATE=(MD4/),' AT ',TIME),                
                                                                        
     HEADER2=(/,15:'Class X Students details',                          
               40:'Page',PAGE,53:' on ',58:DATE=(MD4-),4/,              
          1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 
          1:'-------',11:'--------',30:'----------',45:'-----------'),  
                                                                        
     OUTREC=(1,80)                                                      
/*                                                                      
**************************** Bottom of Data ****************************

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
                   Student Details  Printed on 01/13/2017 AT 05:52:27           
                                                                                
              Class X Students details Page     1    on  01-13-2017             
                                                                                
Std num   Std name           Department     Total marks                         
-------   --------           ----------     -----------                         
00001     student1           dept1          560                                 
00002     student2           dept3          510                                 
                                                                                
              Class X Students details Page     2    on  01-13-2017             
                                                                                
Std num   Std name           Department     Total marks                         
-------   --------           ----------     -----------                         
00003     student3           dept2          520                                 
00004     student4           dept1          540                                 
                                                                                
              Class X Students details Page     3    on  01-13-2017             
                                                                            
Std num   Std name           Department     Total marks                     
-------   --------           ----------     -----------                     
00005     student5           dept2          500                             
00006     student6           dept3          550                             
                                                                            
              Class X Students details Page     4    on  01-13-2017         
                                                                            
Std num   Std name           Department     Total marks                     
-------   --------           ----------     -----------                     
00007     student7           dept3          510                             
00008     student8           dept1          530                             
                                                                            
              Class X Students details Page     5    on  01-13-2017         
                                                                            
Std num   Std name           Department     Total marks                     
-------   --------           ----------     -----------                     
00009     student9           dept2          520                             
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

Explaining Example -

  1. SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
  2. OUTFIL FNAMES=OUTPUT1,.. - Writes the output to the output1 file.
  3. OUTFIL FNAMES=OUTPUT1,LINES=9,BLKCCH2,… - LINES=8 is equal to a single record per page. LINES=9 means two records will be written to page.
  4. OUTFIL FNAMES=OUTPUT1,..,HEADER1=(20:'Student Details',37:'Printed on ',DATE=(MD4/),' AT ',TIME), - Creates the main/overall header.
  5. HEADER2=(/,15:'Class X Students details',40:'Page',PAGE,53:' on ',58:DATE=(MD4-),4/,1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 1:'-------',11:'--------',30:'----------',45:'-----------') - Creates pages level header.
  6. OUTREC=(1,80) - Build the output record from input file of length 80.

Data -


OUTFIL used to set the records per page. LINES statement can be used to specify the number of records per page.

LINES=n, n specifies the number of lines needs to copied per page in the report.

Syntax -


	OPTION COPY
	OUTFIL FNAMES=DDNAMEn, LINES=n
DDNAMEnDDNAME is eight character’s name that representing the actual dataset in JCL.
LINES=nn specifies the number of lines needs to copied per page in the report.
LINES=n is not specified, the default of 60 lines per page is used.

Example -


Scenario - Create the report with data printing 4 records for page.

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001     student1           dept1          560                                 
00003     student3           dept2          520                                 
00004     student4           dept1          540                                 
00005     student5           dept2          500                                 
00002     student2           dept3          510                                 
00006     student6           dept3          550                                 
00008     student8           dept1          530                                 
00007     student7           dept3          510                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Job-card 
//*                                                                     
//**********************************************************************
//*                                                                     
//STEP01   EXEC PGM=SORT                                                
//SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                    
//OUTPUT1  DD DSN=MTHUSER.SORT.OUTPT01,                            
//             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
//             DISP=(NEW,CATLG,DELETE)                                  
//SYSOUT   DD SYSOUT=*                                                  
//SYSIN    DD *                                                         
     SORT FIELDS=(1,5,CH,A)                                             
     OUTFIL FNAMES=OUTPUT1,LINES=11,                                    
                                                                        
     HEADER2=(/,30:'printing Page',PAGE,53:' on ',58:DATE=(MD4-),4/),   
                                                                        
     OUTREC=(1,80)                                                      
                                                                        
/*                                                                      
**************************** Bottom of Data ****************************

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data ********************************
                                                                              
                             printing Page     1     on  01-13-2017           
                                                                              
                                                                              
00001     student1           dept1          560                               
00002     student2           dept3          510                               
00003     student3           dept2          520                               
00004     student4           dept1          540                               
                                                                              
                             printing Page     2     on  01-13-2017           
                                                                              
                                                                              
00005     student5           dept2          500                               
00006     student6           dept3          550                               
00007     student7           dept3          510                               
00008     student8           dept1          530                               
                                                                              
                             printing Page     3     on  01-13-2017           
                                                                                
                                                                                
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

Explaining Example -

  1. SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
  2. OUTFIL FNAMES=OUTPUT1,LINES=11, - Prints 4 lines for page.
  3. HEADER2=(/,30:'printing Page',PAGE,53:' on ',58:DATE=(MD4-),4/) - Creates a page level header.
  4. OUTREC=(1,80) - Build the output record from input file of length 80.

Trailers and statistics -


OUTFIL used to create trailers for reports. OUTFIL can create both report and page trailers. OUTFIL's TRAILER1 is for report trailer andTRAILER2 is for page trailer.

Syntax -


OPTION COPY
OUTFIL FNAMES=DDNAMEn, LINES=n,
	HEADER2=(…..),
	OUTREC=(….),
	TRAILER2=(….)
DDNAMEnDDNAME is eight character’s name that representing the actual dataset in JCL.
TRAILER2=(….)Specifies the trailer

For OUTFIL reports, DFSORT terminates if any header or trailer record is longer than the data records. OUTFIL's BLKCCT1 parameter used to avoid forcing a new page for the report trailer.


Example -


Scenario - Create the report with min,max, avg marks statistics.

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001     student1           dept1          560                                 
00003     student3           dept2          520                                 
00004     student4           dept1          540                                 
00005     student5           dept2          500                                 
00002     student2           dept3          510                                 
00006     student6           dept3          550                                 
00008     student8           dept1          530                                 
00007     student7           dept3          510                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Job-card 
//*                                                                     
//**********************************************************************
//*                                                                     
//STEP01   EXEC PGM=SORT                                                
//SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                    
//OUTPUT1  DD DSN=MTHUSER.SORT.OUTPT01,                            
//             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
//             DISP=(NEW,CATLG,DELETE)                                  
//SYSOUT   DD SYSOUT=*                                                  
//SYSIN    DD *                                                         
     SORT FIELDS=(1,5,ZD,A)                                             
     OUTFIL FNAMES=OUTPUT1,LINES=17,BLKCCH2,                            
                                                                        
     HEADER1=(20:'Student Details',                                     
              37:'Printed on ',DATE=(MD4/),' AT ',TIME),                
                                                                        
     HEADER2=(/,15:'Class X Students details',                          
               40:'Page',PAGE,53:' on ',58:DATE=(MD4-),4/,              
          1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 
          1:'-------',11:'--------',30:'----------',45:'-----------'),  
                                                                        
     OUTREC=(1,80),                                                     
                                                                        
     TRAILER1=(2/,                                                      
               5:'Max  Marks    = ',MAX=(45,3,ZD,M12,LENGTH=10),/,      
               5:'Min  Marks    = ',MIN=(45,3,ZD,M12,LENGTH=10),/,      
               5:'Avg  Marks    = ',AVG=(45,3,ZD,M12,LENGTH=10))        
/*                                                                      
**************************** Bottom of Data ****************************

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
                   Student Details  Printed on 01/13/2017 AT 06:21:18           
                                                                                
              Class X Students details Page     1    on  01-13-2017             
                                                                                
Std num   Std name           Department     Total marks                         
-------   --------           ----------     -----------                         
00001     student1           dept1          560                                 
00002     student2           dept3          510                                 
00003     student3           dept2          520                                 
00004     student4           dept1          540                                 
00005     student5           dept2          500                                 
00006     student6           dept3          550                                 
00007     student7           dept3          510                                 
00008     student8           dept1          530                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
                                                                                
    Max  Marks    =        560                                                  
    Min  Marks    =        500                                                  
    Avg  Marks    =        524                                                  
******************************** Bottom of Data ********************************

Explaining Example -

  1. SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
  2. OUTFIL FNAMES=OUTPUT1,.. - Writes the output to the output1 file.
  3. OUTFIL FNAMES=OUTPUT1,LINES=17,BLKCCH2,… - LINES=8 is equal to a single record per page. LINES=17 means 10 records will be written to page.
  4. OUTFIL FNAMES=OUTPUT1,..,HEADER1=(20:'Student Details',37:'Printed on ',DATE=(MD4/),' AT ',TIME), - Creates the main/overall header.
  5. HEADER2=(/,15:'Class X Students details',40:'Page',PAGE,53:' on ',58:DATE=(MD4-),4/,1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 1:'-------',11:'--------',30:'----------',45:'-----------') - Creates pages level header.
  6. OUTREC=(1,80) - Build the output record from input file of length 80.
  7. TRAILER1=(2/,..) - Adds two empty lines to output file after the data copied from input file.
  8. TRAILER1=(..,5:'Max Marks = ',MAX=(45,3,ZD,M12,LENGTH=10),/,..) - Calculates MAX marks from the Marks from 45th position of length 3 and displays the maximum value from 5th position in the output file.
  9. TRAILER1=(..,/,..) - moves the control to the next line.
  10. TRAILER1=(..,5:'Min Marks = ',MIN=(45,3,ZD,M12,LENGTH=10),/,..) - Calculates MIN marks from the Marks from 45th position of length 3 and displays the maximum value from 5th position in the output file.
  11. TRAILER1=(..,/,..) - moves the control to the next line.
  12. TRAILER1=(..,5:'Avg Marks = ',AVG=(45,3,ZD,M12,LENGTH=10)) - Calculates AVG marks from the Marks from 45th position of length 3 and displays the maximum value from 5th position in the output file.

Sections -


OUTFIL can be used to define sections in the report. OUTFIL's SECTION parameter is used to divide the report up into sections.

Syntax -


OPTION COPY
OUTFIL FNAMES=DDNAMEn, SECTIONS=(starting position, length, SKIP=P/SKIP=nL,
	HEADER2=(…..),
	OUTREC=(….),
	TRAILER2=(….))
DDNAMEnDDNAME is eight character’s name that representing the actual dataset in JCL.
SECTIONS=(..) Specifies the section
SKIP=P Specifies start each section on a new page.
SKIP=nL Specifies sections to appear on the same page, when possible, with n lines between them

HEADER3 creates section headers in the same way that HEADER1 and HEADER2 create report and page headers, respectively. TRAILER3 creates section trailers in the same way that TRAILER 1 and TRAILER2 create report and page trailers, respectively.

Example -


Scenario - Create the report 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 **********************************
00001     student1           dept1          560                                 
00003     student3           dept2          520                                 
00004     student4           dept1          540                                 
00005     student5           dept2          500                                 
00002     student2           dept3          510                                 
00006     student6           dept3          550                                 
00008     student8           dept1          530                                 
00007     student7           dept3          510                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Job-card 
//*                                                                     
//**********************************************************************
//*                                                                     
//STEP01   EXEC PGM=SORT                                                
//SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                    
//OUTPUT1  DD DSN=MTHUSER.SORT.OUTPT01,                            
//             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
//             DISP=(NEW,CATLG,DELETE)                                  
//SYSOUT   DD SYSOUT=*                                                  
//SYSIN    DD *                                                         
     SORT FIELDS=(30,5,CH,A)                                            
     OUTFIL FNAMES=OUTPUT1,                                             
                                                                        
     SECTIONS=(30,5,SKIP=P,                                             
                                                                        
     HEADER3=(3:X,/,                                                    
              3:'Department: ',30,5,/,X,/,                              
          1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 
          1:'-------',11:'--------',30:'----------',45:'-----------'),  
                                                                        
     TRAILER3=(2/,5:'Max  Marks    = ',MAX=(45,3,ZD,M12,LENGTH=10),/,   
               5:'Min  Marks    = ',MIN=(45,3,ZD,M12,LENGTH=10),/,      
               5:'Avg  Marks    = ',AVG=(45,3,ZD,M12,LENGTH=10))),      
     OUTREC=(1,80)                                                      
                                                                        
/*                                                                      
**************************** Bottom of Data ****************************

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
                                                                                
  Department: dept1                                                             
                                                                                
Std num   Std name           Department     Total marks                         
-------   --------           ----------     -----------                         
00001     student1           dept1          560                                 
00004     student4           dept1          540                                 
00008     student8           dept1          530                                 
                                                                                
    Max  Marks    =        560                                                  
    Min  Marks    =        530                                                  
    Avg  Marks    =        543                                                  
                                                                                
  Department: dept2                                                             
                                                                                
Std num   Std name           Department     Total marks                         
-------   --------           ----------     -----------                         
00003     student3           dept2          520                                 
00005     student5           dept2          500                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
                                                                                
    Max  Marks    =        520                                                  
    Min  Marks    =        500                                                  
    Avg  Marks    =        511                                                  
                                                                                
  Department: dept3                                                             
                                                                                
Std num   Std name           Department     Total marks                         
-------   --------           ----------     -----------                         
00002     student2           dept3          510                                 
00006     student6           dept3          550                                 
00007     student7           dept3          510                                 
                                                                                
    Max  Marks    =        550                                                  
    Min  Marks    =        510                                                  
    Avg  Marks    =        523                                                  
******************************** Bottom of Data ********************************

Explaining Example -

  1. SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
  2. OUTFIL FNAMES=OUTPUT1,.. - Writes the output to the output1 file.
  3. SECTIONS=(30,5,SKIP=P, - specifies the section selection criteria. In the above example, the selection criteria is Dept. So given Dept positions.
  4. HEADER3=(3:X,/, 3:'Department: ',30,5,/,X,/,1:'Std num',11:'Std name',30:'Department',45:'Total marks',/,1:'-------',11:'--------',30:'----------',45:'-----------'), - Creates section level header.
  5. TRAILER3=(..) - Creates section level trailer.
  6. TRAILER3=(2/,..) - Adds two empty lines to output file after the data copied from input file.
  7. TRAILER3=(..,5:'Max Marks = ',MAX=(45,3,ZD,M12,LENGTH=10),/,..) - Calculates MAX marks from the Marks from 45th position of length 3 and displays the maximum value from 5th position in the output file.
  8. TRAILER3=(..,/,..) - moves the control to the next line.
  9. TRAILER3=(..,5:'Min Marks = ',MIN=(45,3,ZD,M12,LENGTH=10),/,..) - Calculates MIN marks from the Marks from 45th position of length 3 and displays the maximum value from 5th position in the output file.
  10. TRAILER3=(..,/,..) - moves the control to the next line.
  11. TRAILER3=(..,5:'Avg Marks = ',AVG=(45,3,ZD,M12,LENGTH=10)) - Calculates AVG marks from the Marks from 45th position of length 3 and displays the maximum value from 5th position in the output file.
  12. OUTREC=(1,80) - Build the output record from input file of length 80.