Summary -
In this topic, we described about the OUTFIL Creating Reports with detailed example.
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, andREMOVECC.
The below ones can include 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 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=(….)
Name | Description |
---|---|
DDNAMEn | DDNAME is eight character’s name that representing the actual dataset in JCL. |
HEADER2 | Specifies the header of the report. |
All of the elements in the HEADER2 parameter should be in syncwith 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 -
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 ********************************
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) 001810 //SYSOUT DD SYSOUT=* 002410 //SYSIN DD * 002411 SORT FIELDS=(1,5,ZD,A) 002420 OUTFIL FNAMES=OUTPUT1,LINES=9,BLKCCH2, 002421 002422 HEADER1=(20:'Student Details', 002430 37:'Printed on ',DATE=(MD4/),' AT ',TIME), 002440 002441 HEADER2=(/,15:'Class X Students details', 002450 40:'Page',PAGE,53:' on ',58:DATE=(MD4-),4/, 002460 1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 002470 1:'-------',11:'--------',30:'----------',45:'-----------'), 002480 002490 OUTREC=(1,80) 003500 /* ****** **************************** 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 Solution:
- SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
- OUTFIL FNAMES=OUTPUT1,.. - Writes the output to the output1 file.
- 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.
- OUTFIL FNAMES=OUTPUT1,..,HEADER1=(20:'Student Details',37:'Printed on ',DATE=(MD4/),' AT ',TIME), - Creates the main/overall header.
- 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.
- 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
Name | Description |
---|---|
DDNAMEn | DDNAME is eight character’s name that representing the actual dataset in JCL. |
LINES=n | n 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 -
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 ********************************
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) 001810 //SYSOUT DD SYSOUT=* 002410 //SYSIN DD * 002411 SORT FIELDS=(1,5,CH,A) 002420 OUTFIL FNAMES=OUTPUT1,LINES=11, 002430 002440 HEADER2=(/,30:'printing Page',PAGE,53:' on ',58:DATE=(MD4-),4/), 002460 003000 OUTREC=(1,80) 003100 003500 /* ****** **************************** 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 Solution:
- SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
- OUTFIL FNAMES=OUTPUT1,LINES=11, - Prints 4 lines for page.
- HEADER2=(/,30:'printing Page',PAGE,53:' on ',58:DATE=(MD4-),4/) - Creates a page level header.
- 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=(….)
Name | Description |
---|---|
DDNAMEn | DDNAME 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 -
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 ********************************
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) 001810 //SYSOUT DD SYSOUT=* 002410 //SYSIN DD * 002411 SORT FIELDS=(1,5,ZD,A) 002420 OUTFIL FNAMES=OUTPUT1,LINES=17,BLKCCH2, 002421 002422 HEADER1=(20:'Student Details', 002430 37:'Printed on ',DATE=(MD4/),' AT ',TIME), 002440 002441 HEADER2=(/,15:'Class X Students details', 002450 40:'Page',PAGE,53:' on ',58:DATE=(MD4-),4/, 002460 1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 002470 1:'-------',11:'--------',30:'----------',45:'-----------'), 002480 002490 OUTREC=(1,80), 002500 002600 TRAILER1=(2/, 002700 5:'Max Marks = ',MAX=(45,3,ZD,M12,LENGTH=10),/, 002800 5:'Min Marks = ',MIN=(45,3,ZD,M12,LENGTH=10),/, 002900 5:'Avg Marks = ',AVG=(45,3,ZD,M12,LENGTH=10)) 003500 /* ****** **************************** 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 Solution:
- SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
- OUTFIL FNAMES=OUTPUT1,.. - Writes the output to the output1 file.
- 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.
- OUTFIL FNAMES=OUTPUT1,..,HEADER1=(20:'Student Details',37:'Printed on ',DATE=(MD4/),' AT ',TIME), - Creates the main/overall header.
- 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.
- OUTREC=(1,80) - Build the output record from input file of length 80.
- TRAILER1=(2/,..) - Adds two empty lines to output file after the data copied from input file.
- 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.
- TRAILER1=(..,/,..) - moves the control to the next line.
- 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.
- TRAILER1=(..,/,..) - moves the control to the next line.
- 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=(….))
Name | Description |
---|---|
DDNAMEn | DDNAME 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 -
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 ********************************
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) 001810 //SYSOUT DD SYSOUT=* 002410 //SYSIN DD * 002411 SORT FIELDS=(30,5,CH,A) 002420 OUTFIL FNAMES=OUTPUT1, 002421 002422 SECTIONS=(30,5,SKIP=P, 002441 002445 HEADER3=(3:X,/, 002450 3:'Department: ',30,5,/,X,/, 002460 1:'Std num',11:'Std name',30:'Department',45:'Total marks',/, 002470 1:'-------',11:'--------',30:'----------',45:'-----------'), 002480 002700 TRAILER3=(2/,5:'Max Marks = ',MAX=(45,3,ZD,M12,LENGTH=10),/, 002800 5:'Min Marks = ',MIN=(45,3,ZD,M12,LENGTH=10),/, 002900 5:'Avg Marks = ',AVG=(45,3,ZD,M12,LENGTH=10))), 003000 OUTREC=(1,80) 003100 003500 /* ****** **************************** 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 Solution:
- SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
- OUTFIL FNAMES=OUTPUT1,.. - Writes the output to the output1 file.
- SECTIONS=(30,5,SKIP=P, - specifies the section selection criteria. In the above example, the selection criteria is Dept. So given Dept positions.
- 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.
- TRAILER3=(..) - Creates section level trailer.
- TRAILER3=(2/,..) - Adds two empty lines to output file after the data copied from input file.
- 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.
- TRAILER3=(..,/,..) - moves the control to the next line.
- 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.
- TRAILER3=(..,/,..) - moves the control to the next line.
- 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.
- OUTREC=(1,80) - Build the output record from input file of length 80.