You can add trailers to your report with OUTFIL's TRAILER1 (report trailer) and TRAILER2 (page trailer) parameters. You can use any combination of headers and trailers you need.
Like the HEADERn parameters, the TRAILER1 and TRAILER2 parameters (as well as the TRAILER3 parameter discussed later), let you specify multi-line headings with character strings, hexadecimal strings, input fields, the current date, the current time, page numbers and blank lines. In addition, you can include edited or converted record counts, and edited or converted totals, maximums, minimums, and averages for numeric fields, in your trailers.
SORT FIELDS=(1,15,CH,A)
OUTFIL FNAMES=RPT4,
HEADER2=(1:'BRANCH',18:'REVENUE',28:'PROFIT'),
OUTREC=(1,15,X,
22,6,PD,EDIT=(SIII,IIT),SIGNS=(,-),X,
28,6,PD,EDIT=(SIII,IIT),SIGNS=(,-),
50:X),
TRAILER1=(2/,
3:'Overall results for branches on ',DATE=(MD4/),':',2/,
3:COUNT=(EDIT=(IIT)),' branches are included',2/,
5:'Total revenue = ',
TOT=(22,6,PD,M12,LENGTH=10),/,
5:'Average revenue = ',
AVG=(22,6,PD,M12,LENGTH=10),/,
5:'Lowest revenue = ',
MIN=(22,6,PD,M12,LENGTH=10),/,
5:'Highest revenue = ',
MAX=(22,6,PD,M12,LENGTH=10))
For OUTFIL reports, DFSORT terminates if any header or trailer record is longer than the data records. In this case, the TRAILER1 line with DATE=(MD4/) is 46 bytes long, so the data records must be at least 46 bytes long. To increase the data length set by the OUTREC parameter from 42 bytes to 50 bytes, you can put 50:X at the end of the OUTREC parameter as shown.
COUNT=(EDIT=(IIT)) shows the count of data records as three digits with leading zeros suppressed. TOT=(22,6,PD,M12,LENGTH=10) shows the total revenue as ten bytes of the M12 pattern (that is, SI,III,IIT). Similarly, AVG, MIN and MAX show the average, minimum and maximum, respectively, as ten bytes of the M12 pattern. See Converting numeric fields to different formats and Editing numeric fields, for more information on conversion and editing.
Because LINES=n is not specified, the default of 60 lines per page is used.
1BRANCH 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
Sunnyvale 16,152 -978
Vail 23,202 5,027
1
0 Overall results for branches on 04/16/2005:
0 12 branches are included
0 Total revenue = 329,637
Average revenue = 27,469
Lowest revenue = 12,300
Highest revenue = 42,820
OUTFIL FNAMES=RPT4,BLKCCT1,
1BRANCH 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
Sunnyvale 16,152 -978
Vail 23,202 5,027
0 Overall results for branches on 04/16/2005:
0 12 branches are included
0 Total revenue = 329,637
Average revenue = 27,469
Lowest revenue = 12,300
Highest revenue = 42,820