OUTFIL Creating Reports


OUTFIL is 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 following ones can be included in reports -

  • A cover sheet (report header)
  • A header at the top of each page (page header)
  • A trailer at the bottom of each page (page trailer)
  • A header at the start of each section (section header)
  • A trailer at the end of each section (section trailer)
  • A summary sheet (report trailer)

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

Headers -


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

Syntax -

//SYSIN DD *
  OPTION COPY
  OUTFIL FNAMES=DDNAMEn, 
	HEADER1=(…….),
	OUTREC=(….)
/*
DDname1...DDname-nIt is eight character's name that represents the actual file
HEADER1Creates the report header.
HEADER2Creates the page header.

Points to Note -

  • 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' blank 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., the HEADER1 parameter is used to produce the coversheet information.
  • If we need to start the page heading on the same page as the report heading, OUTFIL's BLKCCH2 parameter should 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 is 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.

Examples -


Scenario1 - Create report header.

//SYSIN    DD *
     SORT FIELDS=(1,5,ZD,A)
     HEADER1=(20:'Student Details',
              37:'Printed on ',DATE=(MD4/),' AT ',TIME),
     OUTREC=(1,80)
/*

Output -

                   Student Details  Printed on 01/13/2017 AT 05:52:27

Scenario2 - Create page header.

//SYSIN    DD *
     SORT FIELDS=(1,5,ZD,A)
     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)
/*

Output -

              Class X Students details Page     1    on  01-13-2017

Data -


OUTFIL with LINES parameter is used to specify the number of records per page.

Syntax -

//SYSIN DD *
	OPTION COPY
	OUTFIL FNAMES=DDNAMEn,LINES=n
/*
LINES=nn specifies the number of lines needs to copied per page in the report. LINES=n is not coded, the default of 60 lines per page is used.

Examples -


Scenario1 - Create the report with data printing 4 records.

//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)
/*

Scenario2 - Create the report with all records.

//SYSIN    DD *
     SORT FIELDS=(1,5,CH,A)
     OUTFIL FNAMES=OUTPUT1,
     HEADER2=(/,30:'printing Page',PAGE,53:' on ',58:DATE=(MD4-),4/),
     OUTREC=(1,80)
/*

Trailers and statistics -


OUTFIL with TRAILER parameter is used to create trailers for reports. It can create both report and page trailers. OUTFIL's TRAILER1 is for report trailer and TRAILER2 is for page trailer.

Syntax -

//SYSIN DD *
  OPTION COPY
  OUTFIL FNAMES=DDNAMEn, LINES=n,
	HEADER2=(…..),
	OUTREC=(….),
	TRAILER2=(….)
/*

For OUTFIL reports, DFSORT terminates the processing 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.

Examples -


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

//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))
/*

Sections -


OUTFIL with SECTION parameter is used to divide the report up into sections.

Syntax -

//SYSIN DD *
  OPTION COPY
  OUTFIL FNAMES=DDNAMEn,
    SECTIONS=(starting position, length, SKIP=P/SKIP=nL,
	HEADER3=(…..),
	OUTREC=(….),
	TRAILER3=(….))
/*
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..TRAILER3Creates section headers and trailers.

Examples -


Scenario1 - Create the report with min, max, avg marks statistics for department.

//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)
/*