z/OS DFSORT Application Programming Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 4

z/OS DFSORT Application Programming Guide
SC23-6878-00

 SORT FIELDS=(3,10,A,16,13,A),FORMAT=CH
 OUTFIL FNAMES=WEST,
   INCLUDE=(42,6,CH,EQ,C'West'),
   HEADER1=(5/,18:'    Western Region',3/,
               18:'Profit and Loss Report',3/,
               18:'     for  ',&DATE,3/,
               18:'      Page',&PAGE),
   OUTREC=(6:16,13,24:31,10,ZD,M5,LENGTH=20,75:X),
   SECTIONS=(3,10,SKIP=P,
     HEADER3=(2:'Division:  ',3,10,5X,'Page:',&PAGE,2/,
              6:'Branch Office',24:'       Profit/(Loss)',/,
              6:'-------------',24:'--------------------'),
    TRAILER3=(6:'=============',24:'====================',/,
              6:'Total',24:TOTAL=(31,10,ZD,M5,LENGTH=20),/,
              6:'Lowest',24:MIN=(31,10,ZD,M5,LENGTH=20),/,
              6:'Highest',24:MAX=(31,10,ZD,M5,LENGTH=20),/,
              6:'Average',24:AVG=(31,10,ZD,M5,LENGTH=20),/,
              3/,2:'Average for all Branch Offices so far:',
                 X,SUBAVG=(31,10,ZD,M5))),
     TRAILER1=(8:'Page ',&PAGE,5X,'Date:  ',&DATE,5/,
               8:'Total Number of Branch Offices Reporting:  ',
                 COUNT,2/,
               8:'Summary of Profit/(Loss) for all',
                 ' Western Division Branch Offices',2/,
               12:'Total:',
                   22:TOTAL=(31,10,ZD,M5,LENGTH=20),/,
               12:'Lowest:',
                   22:MIN=(31,10,ZD,M5,LENGTH=20),/,
               12:'Highest:',
                   22:MAX=(31,10,ZD,M5,LENGTH=20),/,
               12:'Average:',
                   22:AVG=(31,10,ZD,M5,LENGTH=20))

This example illustrates how a report can be produced with a header and trailer page and sections of columns of data, from a sorted subset of fixed-length input records.

The FNAMES parameter specifies the ddname (WEST) associated with the fixed-length data set for the report.

The INCLUDE parameter specifies the records to be selected for the report.

The HEADER1 parameter specifies the report header to appear as the first page of the report, which will consist of five blank lines (5/) followed by four lines of text, each separated by 2 blank lines (3/). The last two lines of text will show the date (&DATE) and page number (&PAGE), respectively.

The OUTREC parameter specifies the two columns of data to appear for each selected input record as follows:
  • The character string from bytes 16 through 28 of the input record.
  • A 20-byte (LENGTH=20) edited numeric value produced by transforming the ZD value in bytes 31 through 40 according to the pattern specified by M5.

The SECTIONS parameter specifies the section break field (3,10), page ejects between sections (SKIP=P), the header (HEADER3) to appear before each section and the trailer (TRAILER3) to appear after each section. The section header will consist of a line of text showing the page number, a blank line (2/) and two lines of text showing the headings for the columns of data. The section trailer will consist of a line of text separating the data from the trailer, lines of text showing the total (TOTAL), minimum (MIN), maximum (MAX) and average (AVG) for the data in the section as edited numeric values, two blank lines, and a line of text showing the running average (SUBAVG) for all of the data records in the report up to this point.

The TRAILER1 parameter specifies the report trailer to appear as the last page of the report, which will consist of a line of text showing the page and date, four blank lines (5/), a text line showing the count of data records in the report, a blank line, a line of text, a blank line, and lines of text showing the total, minimum maximum and average for all of the data in the report as edited numeric values.

75:X is used at the end of the OUTREC parameter to ensure that the data records are longer than the report records. This will result in an LRECL of 76 for the fixed-length OUTFIL data set (1 byte for the ANSI control character and 75 bytes for the data).

The report might look as follows:

                      Western Region


                  Profit and Loss Report


                       for  08/20/05


                        Page     1
Division:  Chips          Page:     2

      Branch Office            Profit/(Loss)
      -------------     --------------------
      Gilroy                     554,843.42
      Los Angeles                (22,340.14)
      Morgan Hill                987,322.32
      Oakland                    234,124.32
      San Francisco              (32,434.31)
      San Jose                 1,232,133.35
      San Martin                 889,022.03
      =============     ====================
      Total                    3,842,670.99
      Lowest                     (32,434.31)
      Highest                  1,232,133.35
      Average                    548,952.99


  Average for all Branch Offices so far:      548,952.99
Division:  Ice Cream      Page:     3

      Branch Office            Profit/(Loss)
      -------------     --------------------
      Marin                      542,341.23
      Napa                       857,342.83
      San Francisco              922,312.45
      San Jose                      (234.55)
      San Martin               1,003,467.30
      =============     ====================
      Total                    3,325,229.26
      Lowest                        (234.55)
      Highest                  1,003,467.30
      Average                    665,045.85


  Average for all Branch Offices so far:      597,325.02
Division:  Pretzels       Page:     4

      Branch Office            Profit/(Loss)
      -------------     --------------------
      Marin                    5,343,323.44
      Morgan Hill                843,843.40
      Napa                     5,312,348.56
      San Francisco            5,412,300.05
      San Jose                 1,234,885.34
      San Martin                  (2,343.82)
      =============     ====================
      Total                   18,144,356.97
      Lowest                      (2,343.82)
      Highest                  5,412,300.05
      Average                  3,024,059.49


  Average for all Branch Offices so far:    1,406,236.51
         Page      5     Date:  08/20/05




        Total Number of Branch Offices Reporting:        18

        Summary of Profit/(Loss) for all Western Division Branch Offices

            Total:          25,312,257.22
            Lowest:            (32,434.31)
            Highest:         5,412,300.05
            Average:         1,406,236.51

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014