PAGE-NUMBER is one of the report writer's built-in counters—a reserved system field you reference but never DEFINE. When PRINT drives a REPORT subactivity, the product tracks how many vertical lines TITLE headings, detail LINE groups, SKIP gaps, control totals, and footers consumed on the current sheet. When the PAGESIZE budget fills, the writer ejects, reprints headings, and bumps PAGE-NUMBER from 1 to 2 to 3 across the run. TITLE line three that says Page followed by PAGE-NUMBER therefore shows the live corner number operators expect on every sheet. Beginners who type the literal Page 1 in quotes ship a payroll register where page forty still says one—a classic audit failure. Veterans pair PAGE-NUMBER with CONTROL RENUM when each REGION must restart numbering at one inside the same physical print file. This page teaches read-only semantics, TITLE embedding, RENUM interaction, ENDPAGE procedure timing, differences from user counters and from PAGE-COUNT on some releases, and why JOB logic that reads PAGE-NUMBER before any PRINT may see meaningless values until the report stream activates.
System variables in Easytrieve arrive pre-defined by the product. You do not code DEFINE PAGE-NUMBER 9 or similar—the compiler treats PAGE-NUMBER as a reserved symbol with report-writer meaning. Attempting to declare your own field with that spelling produces duplicate symbol or unexpected keyword errors. Working storage alternatives like WS-PAGE-DISP are fine when you need to MASK or concatenate PAGE-NUMBER into a longer heading string before TITLE prints it. The system field remains the authoritative source; your W field is a copy for formatting only.
| Event | Effect on PAGE-NUMBER | Beginner notes |
|---|---|---|
| First detail or heading on new report | Usually 1 | Starts fresh per REPORT name in the run |
| PAGESIZE line budget exhausted | Increment by 1 on eject | TITLE reprints on new page |
| CONTROL field RENUM | Reset to 1 after break | Also forces NEWPAGE |
| Explicit page advance in REPORT PROC | May increment per grammar | Confirm on target release |
| JOB restarts mid-file | Typically back to 1 | Unless checkpoint facility preserves state |
TITLE statements accept field names and literals in sequence. A common pattern places the report title on TITLE 01, run date on TITLE 02, and Page plus PAGE-NUMBER on TITLE 03. The report writer evaluates PAGE-NUMBER at format time for that heading line, so the value reflects the page about to print or currently printing depending on procedure timing—test with a fifty-line sample file locally. NOPAGE on TITLE suppresses the default page word the product might inject; you still reference PAGE-NUMBER explicitly when you want custom wording like Sheet instead of Page.
123456REPORT ACME-PAY LINESIZE 132 PAGESIZE 60 TITLESKIP 2 TITLE 01 'ACME PAYROLL REGISTER' TITLE 02 'RUN DATE' SYSDATE TITLE 03 'PAGE' PAGE-NUMBER LINE 01 EMPNO EMPNAME GROSS-PAY CONTROL DEPT
PAGE-NUMBER does not advance on its own clock—it advances because something consumed vertical space. PAGESIZE sets how many lines fit on one page including headings. TITLESKIP adds blank lines after headings. Each detail LINE may span multiple print lines when masks wrap. SKIP after LINE inserts gaps. CONTROL break headers and SUM lines eat budget before the next employee row fits. Beginners set PAGESIZE 60 but stack four TITLE lines plus a fat CONTROL header and wonder why only forty detail rows appear per page; PAGE-NUMBER climbs faster because pagination triggers sooner. Tune headings and PAGESIZE together when PAGE-NUMBER-driven footers must align with operations standards.
Regional payroll packets sometimes require Page 1 on every region cover even inside one spool dataset. CONTROL REGION RENUM starts a new page at the region break and resets PAGE-NUMBER to 1 for the following pages in that region section. Compare with NEWPAGE alone, which ejects without necessarily resetting the counter—RENUM combines both behaviors per Broadcom CONTROL documentation. Mis-applying RENUM on a low-level break like DEPARTMENT restarts numbering every few lines and confuses recipients who expected continuous pages across the enterprise file.
Report function index pages document built-in routines that return page-related values. PAGE-NUMBER as a system field is the declarative counterpart—you place the name directly in TITLE without function-call punctuation on many grammars. Some installations standardize on one style for readability. PAGE-COUNT appears in alternate examples especially with REPORT NOPAGE custom headers; timing in TITLE versus ENDPAGE can differ by release—log ambiguous compile listings and verify on your 11.6 or Plus compiler before production cutover.
Teams sometimes ADD 1 TO WS-PAGE in a REPORT PROC to mimic pagination when migrating legacy code. Prefer PAGE-NUMBER when the report writer already maintains the counter—manual counters drift when SKIP, TITLESKIP, or CONTROL lines change. User counters remain valid for non-REPORT DISPLAY output or audit logs outside the declarative report stream. Never name the user counter PAGE-NUMBER; prefix with WS- or RPT-.
ENDPAGE. PROC runs at page boundaries. Developers test PAGE-NUMBER inside ENDPAGE to print end-of-page subtotals or footers that must appear only when the page fills. Reading PAGE-NUMBER in BEFORE-LINE shows the page active while detail lines stream. JOB INPUT logic that DISPLAYs PAGE-NUMBER before any PRINT to the report usually shows zero or an uninitialized pattern—move diagnostic DISPLAY into REPORT-INPUT or TERMINATION when validating pagination during development.
One program may define REPORT ALPHA and REPORT BETA with separate PRINT statements. PAGE-NUMBER scopes to the report currently printing—ALPHA page 5 does not continue into BETA page 6 unless your flow intentionally chains them and the product shares counters per release rules. Document per-report pagination in job design specs when operations merge spool files by REPORT name.
PAGE-NUMBER is the little number in the corner of your coloring book page. The report robot draws pictures until the page is full, then flips to a new sheet and writes the next corner number. You do not make your own corner-number sticker named PAGE-NUMBER—the robot already has one. If you glue a Page 1 sticker on every sheet yourself, every page lies. RENUM is when the robot starts counting from one again because you began a brand-new chapter in the same book.
1. PAGE-NUMBER is maintained by:
2. You should NOT DEFINE a user field named PAGE-NUMBER because:
3. CONTROL field RENUM affects PAGE-NUMBER by:
4. PAGE-NUMBER in JOB logic before PRINT may:
5. Hard-coding Page 1 in TITLE instead of PAGE-NUMBER causes: