z/OS DFSORT: Getting Started
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Headers

z/OS DFSORT: Getting Started
SC23-6880-00

The preceding output for RPT2 does not look much like a report, but you can fix that by adding page headings with OUTFIL's HEADER2 parameter. This parameter (as well as the HEADER1 and HEADER3 parameters discussed later), lets you specify multi-line headings with character strings, hexadecimal strings, input fields, the current date, the current time, page numbers and blank lines.

The following statements create a report with page headings:
  SORT FIELDS=(1,15,CH,A)
  OUTFIL FNAMES=RPT3,LINES=15,
    HEADER2=(/,3:'Branch Revenue Report',
        30:'Page',PAGE,45:DATE=(MD4-),2/,
      3:'Branch         ',25:' Revenue',50:'  Profit',/,
      3:'---------------',25:'--------',50:'--------'),
    OUTREC=(3:1,15,X,
       25:22,6,PD,EDIT=(SIII,IIT),SIGNS=(,-),X,
       50:28,6,PD,EDIT=(SIII,IIT),SIGNS=(,-))

All of the elements in the HEADER2 parameter should be familiar from the previous discussions of the OUTREC statement, except for the PAGE and DATE=(MD4-) parameters.

PAGE tells DFSORT to print a 6-character page number with leading blanks starting at 1 for the first page and incrementing by 1 for each subsequent page. For page 3, PAGE would give you '     3'. If you wanted to print a 3-character page number with leading zeros, you could use PAGE=(EDIT=(TTT)) or PAGE=(M11,LENGTH=3) or PAGE=(TO=ZD,LENGTH=3). For page 10, these would all give you '010'. See Converting numeric fields to different formats and Editing numeric fields, for more information on conversion and editing.

DATE=(MD4-) tells DFSORT to print the date in the form mm-dd-yyyy. See z/OS DFSORT Application Programming Guidez/OS DFSORT Application Programming Guide for more information on the different forms of the date you can print in headers and trailers.

You do not need to start character strings in headers (HEADERn parameters) or trailers (TRAILERn parameters) with C as you do for the BUILD, OUTREC, OVERLAY, FINDREP, or IFTHEN parameters, although you can if you want to.

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.

The following is a two-page result produced for RPT3:
1
   Branch Revenue Report       Page     1     04-16-2005
0  Branch                   Revenue                   Profit
   ---------------         --------                 --------
   Aspen                     25,800                    5,200
   Boulder                   33,866                    7,351
   Denver                    31,876                    6,288
   Fort Collins              12,300                   -2,863
   Los Angeles               22,530                   -4,278
   Morgan Hill               18,200                    3,271
   Sacramento                42,726                    8,276
   San Diego                 32,940                    8,275
   San Francisco             42,820                    6,832
   San Jose                  27,225                    8,264
1
   Branch Revenue Report       Page     2     04-16-2005
0  Branch                   Revenue                   Profit
   ---------------         --------                 --------
   Sunnyvale                 16,152                     -978
   Vail                      23,202                    5,027
If you print this report, the ANSI carriage control characters tell the printer to eject a page when it sees '1' in the first byte, and to insert a blank line before the lines with '0' in the first byte. So you get a blank line between the 'Branch Revenue Report" line and the "Branch" line in your headers, corresponding to the 2/ in your OUTREC parameter. However, if you view this report on a display, the ANSI carriage control characters are ignored, so the '0' line does not have a blank line before it on the display. To force the blank line to appear whether you print the report or view it on a display, you can change the second line of HEADER2 to:
  30:'Page',PAGE,45:DATE=(MD4-),/,X,/,

This forces DFSORT to write an additional blank output line instead of using the '0' ANSI carriage control character to insert a blank line for the printer. The blank line appears on the printer or display.

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. You can add the following HEADER1 parameter to your OUTFIL statement:
  HEADER1=(20:'Cover sheet for Branch Revenue Report',3/,
           20:'Printed on ',DATE=(MD4/),' at ',TIME),
This separate page is printed at the beginning of the report for RPT3, before the other two pages shown previously. Thus, the first two pages of the report would start like this:
1                   Cover sheet for Branch Revenue Report
-                   Printed on 04/16/2005 at 16:42:20

1   
 Branch Revenue Report       Page     1     04-16-2005  
 ...  
Note that the report heading only has a few lines and then we eject to a new page for the first page heading. If we wanted to start the page heading on the same page as the report heading, we could use OUTFIL's BLKCCH2 parameter. This parameter tells DFSORT to replace the '1' in the first line of the first page heading with a blank, thus avoiding the page eject. With BLKCCH2, the first page of the report would start like this:
1                   Cover sheet for Branch Revenue Report 
-                   Printed on 04/16/2005 at 16:42:20     

 Branch Revenue Report       Page     1     04-16-2005   
 ...  

You can also use OUTFIL's BLKCCH1 parameter to tell 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.

Here are sample JCL statements and control statements for the report using HEADER1, HEADER2, and BLKCCH2:
//HDRPT JOB A492,PROGRAMMER
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=A
//SORTIN DD DSN=A123456.SORT.BRANCH,DISP=SHR
//RPT3   DD SYSOUT=A
//SYSIN DD *
   SORT FIELDS=(1,15,CH,A)
   OUTFIL FNAMES=RPT3,LINES=15,BLKCCH2,
     HEADER1=(20:'Cover sheet for Branch Revenue Report',3/,
              20:'Printed on ',DATE=(MD4/),' at ',TIME),
     HEADER2=(/,3:'Branch Revenue Report',
         30:'Page',PAGE,45:DATE=(MD4-),2/,
       3:'Branch         ',25:' Revenue',50:'  Profit',/,
       3:'---------------',25:'--------',50:'--------'),
     OUTREC=(3:1,15,X,
        25:22,6,PD,EDIT=(SIII,IIT),SIGNS=(,-),X,
        50:28,6,PD,EDIT=(SIII,IIT),SIGNS=(,-))
/*
Of course, you could use a temporary or permanent data set for RPT3 instead of SYSOUT=A. For example:
//RPT3 DD DSN=&&&MYRPT,DISP=(,PASS),SPACE=(CYL,(2,2)),UNIT=SYSDA

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014