MainframeMaster

Pagination

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.

OUTFIL Advanced
Progress0 of 0 lessons

LINES=n: Lines per 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.

How Page Breaks Work

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.

Pagination-related parameters
ParameterEffectNote
LINES=nLines per page; triggers page breaks and repeat of HEADER2/TRAILER2Default often 60
HEADER2=Printed at top of each new pageColumn titles, PAGE, date
TRAILER2=Printed at bottom of each pagePage number, footer
PAGE (in HEADER2)Current page number1, 2, 3, ...
SECTIONS SKIP=PEach section starts on a new pageControl-break on new page

PAGE: Page Number in Headers

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.

Choosing n for LINES=

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.

SECTIONS and SKIP=P

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."

Example: Paginated Report with Page Number

text
1
2
3
4
5
OUTFIL 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.

Explain It Like I'm Five

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.

Exercises

  1. Write an OUTFIL with LINES=50, HEADER2 containing "Page " and PAGE, and a simple BUILD. What happens on page 2?
  2. What is the difference between SKIP=P and SKIP=2L in SECTIONS?
  3. If your report has 200 detail lines and LINES=60, roughly how many pages do you get? How many times is HEADER2 written?
  4. Look up your DFSORT manual: does PAGE support a total page count (e.g. "Page 2 of 5") and what is the keyword?

Quiz

Test Your Knowledge

1. What does LINES=n do on an OUTFIL report?

  • Sets the record length to n
  • Specifies the number of lines per page so that page breaks occur and HEADER2/TRAILER2 repeat on each page
  • Limits total output to n lines
  • Sets the sort key length

2. When does HEADER2 appear in a paginated report?

  • Only once at the start
  • At the top of every page—each time a new page is started after LINES=n lines
  • Only with SECTIONS
  • Only in TRAILER2

3. How do you put the current page number in a report header?

  • Manually in BUILD
  • Use the PAGE keyword (or product equivalent) in HEADER2= so the page number is inserted on each page
  • Only in JCL
  • PAGE is only for SECTIONS

4. What is the typical default for lines per page if LINES= is omitted?

  • No default; no pagination
  • Often 60 lines per page; check your DFSORT manual
  • 1
  • 255

5. What does SKIP=P in SECTIONS do?

  • Skips the first page
  • Starts each section on a new page so section headers and data do not mix with the previous section
  • Prints only every Pth record
  • Same as LINES=