|
Suppose you want to print one page with information about the Computer
department's books, one page with information about the English department's
books, and one page about the History department's books. For each
department's books, you want to show their course numbers, number
in stock, number sold year to date, and price, as well as totals by
department for each of the three numeric (BI) fields. The following
statements create a report with all of this information: INCLUDE COND=(110,4,SS,EQ,C'COMP,ENGL,HIST')
INREC FIELDS=(1:110,4, Course Department
CHANGE=(16,
C'COMP',C'Computer Science',
C'ENGL',C'English',
C'HIST',C'History'),
17:115,5, Course Number
22:162,4, Number in Stock
26:166,4, Number Sold Y-to-D
30:170,4, Price
50:X) Ensure data length greater than header/trailer length
SORT FIELDS=(1,16,CH,A,17,5,CH,A)
OUTFIL FNAMES=RPT5,
SECTIONS=(1,16,SKIP=P,
HEADER3=(3:X,/,
3:'Department: ',1,16,/,X,/,
3:'Number',12:'In Stock',23:'Sold YTD',34:' Price',/,
3:'------',12:'--------',23:'--------',34:'-------'),
TRAILER3=(3:'======',12:'========',23:'========',34:'=======',/,
3:'Totals',
15:TOT=(22,4,BI,EDIT=(IIIIT)),
26:TOT=(26,4,BI,EDIT=(IIIIT)),
34:TOT=(30,4,BI,EDIT=(IIIT.TT)))),
OUTREC=(3:17,5,
15:22,4,BI,EDIT=(IIIIT),
26:26,4,BI,EDIT=(IIIIT),
34:30,4,BI,EDIT=(IIIT.TT))
The INCLUDE statement and INREC statement remove the unneeded records
and fields before sorting. The INREC statement also changes department
identifiers (COMP, ENGL, HIST) to more readable strings. As you learned
previously, the INREC statement changes the starting positions of
various fields, so you must use those new positions for the statements
that are processed after INREC (SORT and OUTFIL in this case).
OUTFIL's SECTION parameter is used to divide the report up into
sections by the course department. 1,16 tells DFSORT to start a new
section every time the department value in columns 1-16 changes.
The SORT statement sorts on the department field to bring all of the
records for each department value together, so only one section is
produced for each department value. If your records are not already
sorted by the section field, use the SORT statement to sort them that
way. You can sort by other fields as well, but the first sort field
must be the section field.
SKIP=P tells DFSORT to start each section on a new page. Alternatively,
you can use SKIP=nL if you want your 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.
OUTFIL's OUTREC parameter is used to reformat the data records
for the report.
The three page result produced for RPT5 is: 1
Department: Computer Science
Number In Stock Sold YTD Price
------ -------- -------- -------
00032 5 29 26.00
00032 6 27 3.60
00032 20 26 18.99
00103 4 23 31.95
00205 10 10 21.99
====== ======== ======== =======
Totals 45 115 102.53
1
Department: English
Number In Stock Sold YTD Price
------ -------- -------- -------
10054 10 9 15.20
10347 7 19 6.25
10347 13 32 14.50
10856 1 26 4.50
10856 2 32 5.95
====== ======== ======== =======
Totals 33 118 46.40
1
Department: History
Number In Stock Sold YTD Price
------ -------- -------- -------
50420 15 9 7.95
50521 14 17 12.00
50632 23 21 17.90
====== ======== ======== =======
Totals 52 47 37.85
Suppose you want to create a second report showing the totals for
each department, but not the data lines. To accomplish this, you
can use a second OUTFIL statement with the NODETAIL (no data), HEADER2
(page headers), SECTIONS (sections) and TRAILER3 (section trailers)
parameters. In this case, because the data lines are not printed,
you do not need to reformat them with the OUTREC parameter. The JCL
and control statements for the complete job to produce your two reports
is: //SCTNRPT JOB A492,PROGRAMMER
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=A
//SORTIN DD DSN=A123456.SORT.SAMPIN,DISP=SHR
//RPT5 DD SYSOUT=A
//RPT6 DD SYSOUT=A
//SYSIN DD *
INCLUDE COND=(110,4,SS,EQ,C'COMP,ENGL,HIST')
INREC FIELDS=(1:110,4, Course Department
CHANGE=(16,
C'COMP',C'Computer Science',
C'ENGL',C'English',
C'HIST',C'History'),
17:115,5, Course Number
22:162,4, Number in Stock
26:166,4, Number Sold Y-to-D
30:170,4, Price
50:X) Ensure data length greater than header/trailer length
SORT FIELDS=(1,16,CH,A,17,5,CH,A)
OUTFIL FNAMES=RPT5,
SECTIONS=(1,16,SKIP=P,
HEADER3=(3:X,/,
3:'Department: ',1,16,/,X,/,
3:'Number',12:'In Stock',23:'Sold YTD',34:' Price',/,
3:'------',12:'--------',23:'--------',34:'-------'),
TRAILER3=(3:'======',12:'========',23:'========',34:'=======',/,
3:'Totals',
15:TOT=(22,4,BI,EDIT=(IIIIT)),
26:TOT=(26,4,BI,EDIT=(IIIIT)),
34:TOT=(30,4,BI,EDIT=(IIIT.TT)))),
OUTREC=(3:17,5,
15:22,4,BI,EDIT=(IIIIT),
26:26,4,BI,EDIT=(IIIIT),
34:30,4,BI,EDIT=(IIIT.TT))
OUTFIL FNAMES=RPT6,
NODETAIL,
HEADER2=(3:'Department ',22:'In Stock',
31:'Sold YTD',42:' Price',/,
3:'----------------',22:'--------',
31:'--------',42:'-------'),
SECTIONS=(1,16,SKIP=0L,
TRAILER3=(3:1,16,
25:TOT=(22,4,BI,EDIT=(IIIIT)),
34:TOT=(26,4,BI,EDIT=(IIIIT)),
42:TOT=(30,4,BI,EDIT=(IIIT.TT))))
/*
The three page report produced for RPT5 is the same as shown previously.
The one page result produced for RPT6 is: 1 Department In Stock Sold YTD Price
---------------- -------- -------- -------
Computer Science 45 115 102.53
English 33 118 46.40
History 52 47 37.85
So far |
---|
So far, you have learned how to create multiple identical
copies of an input data set; select and sample input records by relative
record number for output; include, omit or save selected input records
for output; reformat, repeat and split input records for output; and
create various types of reports. Next, you will learn how to update
counts and totals in trailer records. |
|