Inserting Page Numbers

In this section:

How to:

Reference:

By default, the first two lines of a report page are reserved. The first line contains the page number in the top-left corner, and the second line is blank.

Note: The features in this section are not supported for Compound Reports.

You can:

Note: The variables TABPAGENO and TABLASTPAGE cannot be used to define styling with conditional styling (WHEN).

If you enable Section 508 accessibility, a default page number is not included in the HTML table.


Top of page

x
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


Top of page

x
Syntax: How to Insert the Current Page Number

To add the current page number, add the following to your request.

<TABPAGENO


Example: Inserting the Current Page Number in a Sort Footing

This request generates a new page whenever the value of the sort field REGION changes. It uses TABPAGENO to insert a page number in the sort footing.

TABLE FILE GGSALES
SUM BUDDOLLARS
BY REGION BY ST BY CITY 
ON REGION PAGE-BREAK SUBFOOT
"Sales Quota for <REGION Cities"
"Page <TABPAGENO" 
ON TABLE SET ONLINE-FMT PDF
END

The first page of output is:


Top of page

x
Inserting the Total Page Count

How to:

Reference:

You can use the <TABLASTPAGE system variable to insert the total page count into your report. For example, if you wanted to add a footing in your report that said "Page 1 of 5", you could use the <TABLASTPAGE system variable in conjunction with the <TABPAGENO system variable to do so.



x
Syntax: How to Insert the Total Page Count

To insert the total number of pages, add the following to your request:

<TABLASTPAGE


x
Reference: Usage Notes for TABLASTPAGE


Example: Inserting the Current Page Number and the Total Page Count

The following illustrates how to add the current page number and the total page count to a report. The relevant syntax is highlighted in the request.

TABLE FILE EMPLOYEE
PRINT EMP_ID AS 'Employee ID'
BY SALARY IN-GROUPS-OF 5000 AS 'Salary'
BY PCT_INC AS 'Percent,Increase'
BY DAT_INC AS 'Date of,Increase'
ON SALARY PAGE-BREAK
ON TABLE SET PAGE-NUM OFF
ON TABLE SET STYLE *
TYPE=REPORT, GRID=OFF, $
TYPE=TITLE, STYLE=BOLD, SIZE=11, $
ENDSTYLE
FOOTING 
"Page <TABPAGENO of <TABLASTPAGE" 
END

The first two pages of output are:


Top of page

x
Displaying the Total Page Count Within a Sort Group

How to:

The <BYLASTPAGE variable used in a heading or footing displays the number of pages of output within each sort group when a report uses the REPAGE option to reset the page numbers for each sort group. This variable can only be used with styled output formats.

If the REPAGE option is not used in the report, the total number of pages in the report (<TABLASTPAGE variable) is used for <BYLASTPAGE.



x
Syntax: How to Display the Total Number of Pages Within Each Sort Group

The request must have the following syntax and hold the output in a styled output format:

BY sortfield REPAGE

The heading or footing can use the following syntax to display “Page x of y

{HEADING|FOOTING} 
"Page <TABPAGENO of <BYLASTPAGE"

where:

sortfield

Is the sort field that has the REPAGE option. A PAGE-BREAK is required on the same sort field or a lower level sort field. PAGE-BREAK starts a new page for each sort break. REPAGE resets the page number to 1 for each sort break.

<TABPAGENO

Is the current page number.

<BYLASTPAGE

Is the last page number before the repage.



Example: Paginating Within a Sort Group

The following request against the GGSALES data source sorts by product, region, category, and city. It resets the pagination each time the product changes. The heading prints the current page number and the total within each product group.

Note that by default, the TABPAGENO and BYLASTPAGE variables have format I5, which leaves a lot of blank space before the page numbers. Therefore, you can use spot markers or COMPUTE commands to move the page numbers to the left.

In the following example, a COMPUTE command creates a field named X that has the value of TABPAGENO but stores it as an I2 field, and the spot marker in the heading moves the BYLASTPAGE page number four spaces to the left. The heading command must come after the COMPUTE command or the field named X will not be recognized:

TABLE FILE GGSALES                          
SUM UNITS                                   
COMPUTE X/I2 = TABPAGENO;
BY PRODUCT NOPRINT REPAGE        
BY REGION PAGE-BREAK                        
BY CATEGORY                                 
BY CITY                                     
HEADING CENTER  
"<PRODUCT : Page <X of <-4> <BYLASTPAGE "
ON TABLE PCHOLD FORMAT PDF           
END                                         

The following partial output shows that the page number resets to 1 when the product changes and that the BYLASTPAGE variable displays the total number of pages for each product:


Top of page

x
Assigning Any Page Number to the First Page

How to:

You can assign a page number to the first page of a report using the FOCFIRSTPAGE parameter. This feature is useful when a report is printed and assembled as part of another one.

You can also control the page numbering of multiple reports in the same procedure using the FOCFIRSTPAGE parameter with the &FOCNEXTPAGE variable.

If TABPAGENO is used, FOCFIRSTPAGE is ignored.



x
Syntax: How to Assign a Page Number to the First Page

For all report requests in a procedure

SET FOCFIRSTPAGE = {n|1|&FOCNEXTPAGE}

For one report request

ON TABLE SET FOCFIRSTPAGE {n|1|&FOCNEXTPAGE}

where:

n

Is an integer between 1 and 999999, which is the number assigned to the first page of the report.

1

Assigns the number 1 to the first page. 1 is the default value.

&FOCNEXTPAGE

Is a variable whose value is one more than the last page number of the previous report in a multiple request. The value is calculated at run time.



Example: Assigning a Page Number to the First Page

This request assigns the number 3 to the first page of the report.

SET FOCFIRSTPAGE = 3 
TABLE FILE CENTORD
HEADING
"Sales By Store"
SUM LINEPRICE AS 'Sales'
BY SNAME
ON TABLE SET STYLE *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END

The report is:



Example: Controlling Page Numbers in Consecutive Reports

This procedure contains two report requests. The second request sets FOCFIRSTPAGE to the value of &FOCNEXTPAGE.

SET FOCFIRSTPAGE = 3
TABLE FILE CENTORD
HEADING
"Sales By Store"
SUM LINEPRICE AS 'Sales'
BY SNAME
WHERE SNAME EQ 'eMart'
ON TABLE SET STYLE *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END
-RUN
SET FOCFIRSTPAGE = &FOCNEXTPAGE 
TABLE FILE CENTORD
HEADING
"Sales By Product"
SUM LINEPRICE AS 'Sales'
BY PRODCAT AS 'Product'
WHERE PRODCAT EQ 'VCRs'
ON TABLE SET STYLE *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END

The first page of the second report is numbered 4, which is one more than the last page of the previous report:


Top of page

x
Controlling the Display of Page Numbers

How to:

By default, the first two lines of a report page are reserved. The first line displays the page number in the top-left corner, and the second line is blank. To suppress the default display, use the PAGE-NUM parameter.



x
Syntax: How to Control the Display of Page Numbers

For all report requests in a procedure

SET PAGE[-NUM] = num_display

For one report request

ON TABLE SET PAGE[-NUM] num_display

where:

-NUM

Is optional. PAGE and PAGE-NUM are synonymous.

num_display

Is one of the following:

ON displays page numbers in the top-left corner, followed by a reserved blank line. ON is the default value.

OFF suppresses default page numbers.

You can use the system variable TABPAGENO.

NOPAGE suppresses default page numbers and makes the top two lines of a page available for your use.

You can use the system variable TABPAGENO.

TOP or NOLEAD removes the line at the top of each page reserved for the page number, and the blank line after it. The first line of a report contains the report or page heading if specified, or column titles if there is no heading.

You can use the system variable TABPAGENO to show page numbers elsewhere in the report.



Example: Suppressing Default Page Numbers

This request uses SET PAGE-NUM = NOPAGE to suppress default page numbers. It uses the top line of the first page of the report for the report heading.

SET PAGE-NUM = NOPAGE 
TABLE FILE GGPRODS
ON TABLE SUBHEAD
"PACKAGING INFORMATION"
" "
PRINT PACKAGE_TYPE AND SIZE AND UNIT_PRICE
BY PRODUCT_DESCRIPTION
ON PRODUCT_DESCRIPTION PAGE-BREAK SUBFOOT
"PRODUCT ID <PRODUCT_ID"
"Page <TABPAGENO "
ON TABLE SET ONLINE-FMT PDF
END

TABPAGENO inserts the page number in the sort footing. The first page of the report is:


WebFOCUS