In DFSORT report output, headers and trailers are the lines that frame your data: a report header (HEADER1) at the very start—often the report title and run date/time—a page header (HEADER2) that repeats on each page—typically column titles and page number—and trailers: a report trailer (TRAILER1) at the end with record count or grand total, and a page trailer (TRAILER2) at the bottom of each page. When you use SECTIONS= for control breaks, you also get a section header (HEADER3) and section trailer (TRAILER3) for each group. This page focuses on what to put in each type of header and trailer (titles, dates, page numbers, counts, totals), positioning and multi-line content (using the slash /), and options like BLKCCH1 so the report prints without unwanted page ejects. For full OUTFIL syntax, see Headers and trailers (OUTFIL).
A report has a clear structure. Knowing where each piece of text goes helps you choose the right parameter:
| Parameter | When it appears | Typical content |
|---|---|---|
| HEADER1 | Once at the very beginning | Report title, run date (DATE=), run time (TIME=), company or department name. |
| HEADER2 | Top of each page (when LINES= is used) | Column titles, short title, page number (PAGE). |
| HEADER3 | Start of each section (when SECTIONS= is used) | Section key (e.g. department name), section subtitle. |
| TRAILER1 | Once at the very end | Record count (COUNT=), grand total, "END OF REPORT." |
| TRAILER2 | Bottom of each page | Page number (PAGE), "Continued", or short footer. |
| TRAILER3 | End of each section | Section subtotal, section record count. |
HEADER1 is the first thing the reader sees. Use it for the report title (e.g. "MONTHLY SALES REPORT"), the run date and time (DATE= and TIME=), and any one-time text (e.g. department or parameter). You can use positioning to place text at specific columns—e.g. 1:'Title' and 60:DATE to put the date on the right side of an 80-column line.
1HEADER1=(1:'SALES REPORT',/,1:'Run date: ',DATE=(MD4-),25:'Run time: ',TIME)
The first line is "SALES REPORT"; the second line (after /) has "Run date: ", the date in MM-DD-YYYY form, and "Run time: " plus the time. DATE= and TIME= formats are product-dependent (e.g. MD4, MD4-, Y2Y for date; check your manual).
HEADER2 repeats on every page. Use it for column titles (e.g. "ID", "Name", "Amount") so each page has a header line that matches the detail columns. You can also put the page number (PAGE) in HEADER2—e.g. "Page ", PAGE at a fixed position. Keep HEADER2 short so it does not use too many of the LINES= per page; one or two lines is typical.
1HEADER2=(1:'ID',11:'Name',41:'Amount',60:'Page ',PAGE)
One line: column titles at 1, 11, 41, and "Page " plus PAGE at 60. So every page has the same header with the correct page number.
TRAILER1 appears once at the end of the report. Use it for the record count (COUNT= or product equivalent), a grand total (if supported), and any closing text (e.g. "END OF REPORT"). The count or total is computed after all detail records are written, so TRAILER1 is the right place for report-level summary information.
1TRAILER1=(1:'Total records: ',COUNT=(M10,LENGTH=10),/,1:'*** END OF REPORT ***')
First line: "Total records: " and the count (formatted with M10, length 10). Second line: "*** END OF REPORT ***". Exact COUNT= syntax (M10, LENGTH=, etc.) is product-dependent; see your DFSORT manual.
TRAILER2 is at the bottom of each page. Use it for the page number (if you prefer it at the bottom), "Continued on next page", or a short footer. TRAILER3 is used with SECTIONS=: it appears after each control-break group. Put section-level information there—e.g. subtotal for that section or "Section end." So TRAILER2 is per-page; TRAILER3 is per-section.
In HEADER1=, HEADER2=, TRAILER1=, and TRAILER2=, the slash (/) starts a new line. So you can build multi-line titles and footers. Example:
1HEADER1=(1:'ACME CORPORATION',/,1:'SALES REPORT',/,1:'Period: ',50:DATE)
Three lines: "ACME CORPORATION", then "SALES REPORT", then "Period: " and the date at position 50. Use as many lines as you need; each / begins a new line.
You control where text appears using position:content. For example 1:'Title' puts "Title" at column 1; 60:DATE puts the date starting at column 60 (right side of an 80-column line). You can mix positioned and non-positioned items; order determines the default position when not specified. So you can left-align the title and right-align the date in the same header line.
On some systems, the first byte of each line is used for carriage control (e.g. "1" = new page, "0" = space one line). If HEADER1 or HEADER2 starts with a control character that means "eject page," you may get a blank page before or after the header. BLKCCH1 tells DFSORT to replace the first character of the first line of HEADER1 with a blank so the report title does not force a page eject. BLKCCH2 does the same for HEADER2. Use them when the report is going to a printer or dataset that interprets carriage control and you want the header on the same page as the data.
When you use SECTIONS=(position,length,...), records are grouped (e.g. by department). HEADER3 is output at the start of each section—e.g. the department name or a subtitle. TRAILER3 is output at the end of each section—e.g. a subtotal or "Section total." So you get a header and trailer around each group for classic control-break reporting. See Control break reporting and Report totals for subtotal/total syntax.
Think of a report like a letter. The first line might say "SALES REPORT" and "January 2025"—that's the report header (HEADER1). Every new page has a line at the top that says "ID, Name, Amount" and "Page 2"—that's the page header (HEADER2). At the very end you write "Total: 100 records" and "The End"—that's the report trailer (TRAILER1). DFSORT lets you define exactly what goes in those top and bottom lines so your report looks finished and professional.
1. What is the best use of HEADER1 in a report?
2. Where do you put the record count or grand total in a report?
3. How do you get multiple lines in a header or trailer?
4. What is the difference between TRAILER2 and TRAILER3?
5. Why would you use BLKCCH1 in a report?