Pagination in DFSORT report output means breaking the report into pages of a fixed number of lines and repeating a page header (HEADER2) and optionally a page trailer (TRAILER2) on each page. You control page size with LINES=n: after n lines are written, DFSORT starts a new page and prints HEADER2 again at the top and TRAILER2 again at the bottom. So each page has the same structure—header, detail lines, footer—which is what you want for printed or PDF-style reports. Without LINES=, there is either a single long page or a product default (often 60 lines). This page covers LINES=, how HEADER2 and TRAILER2 interact with pagination, the PAGE keyword for page numbers, and SKIP=P in SECTIONS to start each section on a new page.
LINES=n is the OUTFIL parameter that sets the page length. It tells DFSORT: after every n lines of output (typically counting detail lines and any header/trailer lines that count toward the page), start a new page. When a new page starts, the page header (HEADER2) is written at the top and, if you specified one, the page trailer (TRAILER2) is written at the bottom of the previous page (or at the bottom of each page, depending on product). So you get consistent page breaks and repeating headers and footers. For example, LINES=55 is common for 11-inch paper at 6 lines per inch (66 lines total, minus a few for margins—55 leaves room for header and trailer). If you omit LINES=, many DFSORT products default to 60 lines per page; check your manual for the exact default.
DFSORT writes the report in order: first HEADER1 (report header), then for page 1 it writes HEADER2 (page header), then detail lines until the page is "full" (n lines used), then TRAILER2 (page trailer) if present. Then it starts page 2: HEADER2 again, then more detail lines, then TRAILER2 again. This continues until all detail records are written. At the end it writes TRAILER1 (report trailer) once. So HEADER2 and TRAILER2 are the ones that repeat; HEADER1 and TRAILER1 appear once. The exact way lines are counted (whether header/trailer lines count toward the n or are extra) can be product-dependent; the idea is that LINES= controls how often a new page is started and thus how often HEADER2 and TRAILER2 are emitted.
| Parameter | Effect | Note |
|---|---|---|
| LINES=n | Lines per page; triggers page breaks and repeat of HEADER2/TRAILER2 | Default often 60 |
| HEADER2= | Printed at top of each new page | Column titles, PAGE, date |
| TRAILER2= | Printed at bottom of each page | Page number, footer |
| PAGE (in HEADER2) | Current page number | 1, 2, 3, ... |
| SECTIONS SKIP=P | Each section starts on a new page | Control-break on new page |
To print the current page number on each page, use the PAGE keyword inside HEADER2=. Because HEADER2 is repeated for each page, PAGE will automatically show 1 on the first page, 2 on the second, and so on. You typically combine it with fixed text and positioning—for example, 40:\'Page \',PAGE,53:\' on \',58:DATE=(MD4-) might produce "Page 1 on 01-14-2025" on the first page and "Page 2 on 01-14-2025" on the second. Some products support a total page count (e.g. "Page 2 of 10") with a keyword like TOTALPAGES or PAGETOTAL; see your DFSORT manual for exact syntax.
Choose n based on your physical page size and font. For standard 11"×8.5" paper at 6 lines per inch, you get about 66 lines per page; leaving a few lines for top and bottom margins and for HEADER2/TRAILER2, LINES=55 or LINES=60 is common. For A4 or other sizes, adjust accordingly. If the report is only viewed online, you can still use LINES= to get logical "pages" (e.g. 40 lines per screen). The important point is that once n is set, every page has the same structure and HEADER2/TRAILER2 repeat consistently.
When you use SECTIONS= for control-break reporting, you can specify SKIP=P (skip to new page) so that each section starts on a new page. After TRAILER3 for one section, the next section does not continue on the same page—instead, a new page is started and HEADER3 for the next section is printed at the top. So you get one section per page, which is useful when each group (e.g. each department) should be on its own page. Alternatively, SKIP=nL keeps sections on the same page with n blank lines between them. So SKIP=P is for "new page per section"; SKIP=nL is for "same page, n lines between sections."
12345OUTFIL FNAMES=REPORT,LINES=55, HEADER1=(20:'Monthly Report',37:DATE=(MD4/),' AT ',TIME), HEADER2=(/,1:'ID',11:'Name',41:'Amount',/,40:'Page ',PAGE,53:' of report',/), BUILD=(1,10,11,30,41,10,PD,M12,LENGTH=12), TRAILER2=(/,1:80X)
LINES=55 gives 55 lines per page. HEADER2 repeats on each page and includes "Page " and PAGE so each page shows its number. TRAILER2 is a blank line (80 spaces) at the bottom of each page. Adjust PAGE/total page syntax to match your product.
Imagine a long list of names. Instead of one endless list, you want to put them in a book: each page has a title at the top (like "Class List — Page 2") and maybe a line at the bottom. LINES= is the rule that says "only put 55 lines on each page." When the page is full, you turn to a new page and write the title again at the top. So every page looks the same: title on top, list in the middle, maybe a footer. Pagination is just that—splitting the report into pages and repeating the top and bottom on each page.
1. What does LINES=n do on an OUTFIL report?
2. When does HEADER2 appear in a paginated report?
3. How do you put the current page number in a report header?
4. What is the typical default for lines per page if LINES= is omitted?
5. What does SKIP=P in SECTIONS do?