Creating Paging and Numbering

In this section:

The appearance of your report can be enhanced by controlling paging and page numbering. You can:

Specifying a Page Break: PAGE-BREAK

How to:

Reference:

Use the PAGE-BREAK option to start a new page each time the specified sort field value changes, or to prevent information that should be grouped together from being presented over more than one page.

To specify a page break, use PAGE-BREAK in either an ON phrase or BY phrase immediately after the sort field on which you want to break the page. Put the PAGE-BREAK command on the lowest-level sort field at which the page break is to occur. You can also use PAGE-BREAK to:

Syntax: How to Specify a Page Break

The syntax is:

{ON|BY} fieldname PAGE-BREAK [REPAGE][WHEN expression;]

where:

fieldname

Is a sort field. A change in the sort field value causes a page break.

REPAGE

Resets the page number to 1 at the sort break or, if WHEN is used, whenever the conditions in the WHEN clause are met.

WHEN expression

Specifies conditional page breaks in the printing of a report, as determined by a Boolean expression (see Conditionally Formatting Reports With the WHEN Clause).

Reference: Usage Notes for Page Breaks

  • Page headings and column titles appear at the top of each new page.
  • Page breaks automatically occur whenever a higher-level sort field changes.
  • PAGE-BREAK is ignored when report output is stored in HOLD, SAVE, or SAVB files (see Saving and Reusing Your Report Output).
  • When the request has a PAGE-BREAK, the GRANDTOTAL is on a page by itself.

Example: Specifying a Page Break

TABLE FILE EMPLOYEE
PRINT EMP_ID
BY SALARY IN-GROUPS-OF 5000
BY PCT_INC BY DAT_INC
ON SALARY PAGE-BREAK
END

The first two pages of this report display as:

PAGE     1                                   
                                             
                                             
         SALARY  PCT_INC   DAT_INC  EMP_ID   
         ------  -------   -------  ------   
      $5,000.00      .00  82/01/04  119265415
                          82/04/01  543729165
                     .04  82/06/11  543729165
                     .05  82/05/14  119265415
PAGE     2                                   
                                             
                                             
         SALARY  PCT_INC   DAT_INC  EMP_ID   
         ------  -------   -------  ------   
     $10,000.00      .10  82/01/01  071382660
                                    112847612
                     .12  81/01/01  071382660

Inserting Page Numbers: TABPAGENO

By default, FOCUS reserves the first two lines of each report page: the first line contains the page number at the left margin—that is, in the top-left corner of the page—and the following line is blank. You can change the position of the page number with the TABPAGENO system variable.

TABPAGENO contains the page number of the current page and acts like a field name. Therefore, it can be positioned in a heading or footing (or subhead/subfoot). The default page number in the top left-hand corner is automatically suppressed when this variable is used.

Note:

Example: Inserting Page Numbers

This request

TABLE FILE PROD
"<TABPAGENO"
PRINT PACKAGE AND UNIT_COST
BY PROD_NAME BY PROD_CODE
ON PROD_NAME PAGE-BREAK
END

creates the following report (of which the first two pages are shown):

    1                                              
PROD_NAME        PROD_CODE  PACKAGE       UNIT_COST
---------        ---------  -------       ---------
AMERICAN CHEESE  C7         8 OUNCES          $2.19
    2                                              
PROD_NAME        PROD_CODE  PACKAGE       UNIT_COST
---------        ---------  -------       ---------
BUTTER MILK      C14        32 OUNCES         $1.89

Note that FOCUS continues to reserve the top two lines of every report page.

Controlling Report Page Numbering

How to:

Reference:

The SET FOCFIRSTPAGE command enables you to designate the first page number on a report. You can set FOCFIRSTPAGE to a specific number or the value of a Dialogue Manager variable. The &FOCNEXTPAGE variable enables you to establish consecutive page numbering across multiple reports.

When a report is processed, the variable &FOCNEXTPAGE is set to the number following the last page number in the report. This value can then be used as the first page number in a subsequent report, making the report output from multiple requests more useful and readable.

Consecutive page numbering can span multiple -INCLUDE commands.

If TABPAGENO is used in a request with FOCFIRSTPAGE, it correctly reflects the page number set by FOCFIRSTPAGE.

Syntax: How to Set the First Page Number for a Report

At the command line, in a FOCEXEC, or in a FOCUS-supported profile:

SET FOCFIRSTPAGE = {n|&var}

In a TABLE request:

ON TABLE SET FOCFIRSTPAGE {n|&var}

where:

n

Is the one- to six-digit number to be assigned to the first page of report output. The default value is 1.

&var

Is a Dialogue Manager variable whose value is used as the first page number of the report. &FOCNEXTPAGE is a system variable whose value is one greater than the last page of the prior report.

Example: Setting the Number of the First Page of a Report

This example runs two report requests, each of which uses TABPAGENO in its heading:

  • The first report displays a list of movies.
  • The second report displays movies with specific ratings. The SET FOCFIRSTPAGE command prior to the second report causes it to start with the next consecutive page number after the end of the first report.

The following procedure contains both report requests:

TABLE FILE MOVIES
HEADING
"MOVIES BY CATEGORY AND DIRECTOR:     PAGE <TABPAGENO "
" "
PRINT RATING TITLE
BY CATEGORY BY DIRECTOR
WHERE CATEGORY EQ 'ACTION' OR 'MUSICALS' OR 'COMEDY' OR 'CHILDREN'
WHERE DIRECTOR NE ' '
WHERE RATING NE 'NR'
END
 
-RUN
SET FOCFIRSTPAGE=&FOCNEXTPAGE
 
TABLE FILE MOVIES
HEADING
"MOVIES APPROPRIATE FOR CHILDREN:       PAGE <TABPAGENO "
" "
PRINT TITLE
BY CATEGORY BY DIRECTOR BY RATING
WHERE CATEGORY EQ 'ACTION' OR 'MUSICALS' OR 'COMEDY' OR 'CHILDREN'
WHERE DIRECTOR NE ' '
WHERE RATING EQ 'G' OR RATING CONTAINS 'PG'
END

The first report has pages 1 and 2. The output is:

MOVIES BY CATEGORY AND DIRECTOR:     PAGE     1
 
CATEGORY  DIRECTOR           RATING  TITLE
--------  --------           ------  -----
ACTION    MCDONALD P.        R       RAMBO III
          SCOTT T.           PG      TOP GUN
          SPIELBERG S.       PG      JAWS
          VERHOVEN P.        R       ROBOCOP
                             R       TOTAL RECALL
CHILDREN  BARTON C.          G       SHAGGY DOG, THE
          DISNEY W.          G       BAMBI
          GEROMINI           G       ALICE IN WONDERLA
COMEDY    ABRAHAMS J.        PG      AIRPLANE
          ALLEN W.           PG      ANNIE HALL
          BROOKS J.L.        R       BROADCAST NEWS
          HALLSTROM L.       PG13    MY LIFE AS A DOG
          MARSHALL P.        PG      BIG
          ZEMECKIS R.        PG      BACK TO THE FUTUR
MUSICALS  ATTENBOROUGH R.    PG13    CHORUS LINE, A
          FOSSE B.           PG      CABARET
 
MOVIES BY CATEGORY AND DIRECTOR:     PAGE     2
 
CATEGORY  DIRECTOR           RATING  TITLE
--------  --------           ------  -----
MUSICALS  FOSSE B.           R       ALL THAT JAZZ
          JEWISON N.         G       FIDDLER ON THE ROOF

The second report starts on page 3. The output is:

MOVIES APPROPRIATE FOR CHILDREN:       PAGE     3
 
CATEGORY  DIRECTOR           RATING  TITLE
--------  --------           ------  -----
ACTION    SCOTT T.           PG      TOP GUN
          SPIELBERG S.       PG      JAWS
CHILDREN  BARTON C.          G       SHAGGY DOG, THE
          DISNEY W.          G       BAMBI
          GEROMINI           G       ALICE IN WONDERLAND
COMEDY    ABRAHAMS J.        PG      AIRPLANE
          ALLEN W.           PG      ANNIE HALL
          HALLSTROM L.       PG13    MY LIFE AS A DOG
          MARSHALL P.        PG      BIG
          ZEMECKIS R.        PG      BACK TO THE FUTURE
MUSICALS  ATTENBOROUGH R.    PG13    CHORUS LINE, A
          FOSSE B.           PG      CABARET
          JEWISON N.         G       FIDDLER ON THE ROOF

Reference: Page Number Commands

Command

Description

Applies to

<BYLASTPAGE

Used with REPAGE. Inserts the total page count within the sort group that has the REPAGE option.

HTML

PDF

PS

PPTX

REPAGE

Resets page number to one.

HTML

PDF

PS

PPTX

<TABPAGENO

Inserts the current page number. TABPAGENO suppresses the default page number, and the top two lines of a page are blank.

HTML

PDF

PS

PPTX

<TABLASTPAGE

Inserts the total page count in the report.

HTML

PDF

PS

PPTX

SET FOCFIRSTPAGE

Assigns the designated page number to the first page.

HTML

PDF

PS

PPTX

SET PAGE-NUM

Controls page number display.

HTML

PDF

PS

Suppressing Page Numbers: SET PAGE

How to:

Automatic page numbering can also be suppressed with the SET PAGE command.

Syntax: How to Suppress Page Numbers

To suppress page numbering, the syntax is:

SET PAGE = {OFF|NOPAGE|TOP}

where:

OFF

Suppresses automatic page numbering. You can still use the variable TABPAGENO as described in Inserting Page Numbers: TABPAGENO. Note that FOCUS reserves the top two lines of every page.

NOPAGE

Suppresses all page indicators and makes the first two lines of each report page available for your use. NOPAGE does not issue page ejects; they are issued if you use SET PAGE=OFF.

TOP (or NOLEAD)

Omits the line at the top of each page of the report output for the page number and the blank line that follows it. The first line of the report output contains the heading, if one is specified, or the column titles, if there is no heading.

Preventing an Undesirable Split: NOSPLIT

How to:

Reference:

Page breaks sometimes occur where report information has been logically grouped by sort field(s), causing one or two lines to appear by themselves on the next page or screen. To prevent this, use NOSPLIT in either an ON phrase, or immediately after the first reference to the sort field in a BY phrase.

Syntax: How to Prevent an Undesirable Split

{ON|BY} fieldname NOSPLIT

where:

fieldname

Is the name of the sort field for which the sort groups are kept together on the same page.

Whenever the value of the specified field changes, FOCUS determines if the total number of lines related to the new value can fit on the current page. If they cannot, the page breaks and the group of lines appears on the next page.

Reference: Usage Notes for Preventing an Undesirable Split

  • Only one NOSPLIT option is allowed per report. If a PAGE-BREAK option also exists in the request, it must relate to a higher-level sort field; otherwise, NOSPLIT is ignored.
  • Subtotals, footings, subheads, and subfoots are placed on the same page as the detail lines; headings are placed on the new page.
  • NOSPLIT is ignored when report output is stored in HOLD, SAVE, or SAVB files (see Saving and Reusing Your Report Output).
  • NOSPLIT is not compatible with the TABLEF command, and produces an FOC037 error message.

Example: Preventing an Undesirable Split

TABLE FILE EMPLOYEE
PRINT DED_CODE AND DED_AMT
BY PAY_DATE BY LAST_NAME
ON LAST_NAME NOSPLIT
END

Depending upon how many lines your output device is set to, the first two pages of the previous request might display as:

PAGE     1                                          
                                                    
                                                    
PAY_DATE  LAST_NAME        DED_CODE          DED_AMT
--------  ---------        --------          -------
81/11/30  CROSS            CITY                $7.52
                           FED               $638.96
                           FICA              $526.20
                           HLTH               $32.22
                           LIFE               $19.33
                           SAVE               $77.32
                           STAT              $105.24
          STEVENS          CITY                 $.83
                           FED                $70.83
                           FICA               $58.33
                           STAT               $11.67
PAGE     2                                          
                                                    
                                                    
PAY_DATE  LAST_NAME        DED_CODE          DED_AMT
--------  ---------        --------          -------
81/12/31  CROSS            CITY                $7.52
                           FED               $638.96
                           FICA              $526.20
                           HLTH               $32.22
                           LIFE               $19.33
                           SAVE               $77.32
                           STAT              $105.24
          STEVENS          CITY                 $.83
                           FED                $70.83
                           FICA               $58.33
                           STAT               $11.67

Here are the first two pages without NOSPLIT:

PAGE     1                                          
                                                    
                                                    
PAY_DATE  LAST_NAME        DED_CODE          DED_AMT
--------  ---------        --------          -------
81/11/30  CROSS            CITY                $7.52
                           FED               $638.96
                           FICA              $526.20
                           HLTH               $32.22
                           LIFE               $19.33
                           SAVE               $77.32
                           STAT              $105.24
          STEVENS          CITY                 $.83
                           FED                $70.83
                           FICA               $58.33
                           STAT               $11.67
81/12/31  CROSS            CITY                $7.52
                           FED               $638.96
                           FICA              $526.20
                           HLTH               $32.22
                           LIFE               $19.33
                           SAVE               $77.32
PAGE     2                                          
                                                    
                                                    
PAY_DATE  LAST_NAME        DED_CODE          DED_AMT
--------  ---------        --------          -------
81/12/31  CROSS            STAT              $105.24
          STEVENS          CITY                 $.83
                           FED                $70.83
                           FICA               $58.33
                           STAT               $11.67
82/01/29  CROSS            CITY                $7.52
                           FED               $638.96
                           FICA              $526.20
                           HLTH               $32.22
                           LIFE               $19.33
                           SAVE               $77.32
                           STAT              $105.24
          IRVING           CITY                $6.10
                           FED               $518.92
                           FICA              $427.35
                           HLTH               $50.87
                           LIFE               $30.52

The report without NOSPLIT has an undesirable split for Cross on Page 2, whereas the report using NOSPLIT does not.


Information Builders