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.

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

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:

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.

Syntax: How to Insert the Total Page Count

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

<TABLASTPAGE

Reference: Usage Notes for TABLASTPAGE

  • TABLASTPAGE does not adjust for changes in FOCFIRSTPAGE or for the REPAGE command. For example, if the report has 10 pages and the user uses FOCFIRSTPAGE to set the first page number to 3 rather than 1, the value of TABLASTPAGE will still be 10.
  • TABLASTPAGE is supported only for a single report, not compound reports. A separate page count is generated for each report in a compound report.
  • TABLASTPAGE is supported only for styled reports such as HTML, PDF, and PS. it is not supported for EXL2K, WP, DOC, or HTML with STYLE=OFF and STYLEMODE=FIXED.
  • TABLASTPAGE causes a second pass through the report results, first to calculate the last page then to print it with TABPAGENO (even when SQUEEZE=OFF).
  • TABLASTPAGE does not support the system (external) sort.
  • GRAPH FILE does not support TABLASTPAGE.
  • TABLEF is not supported with 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:

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.

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:

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.

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:

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.

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:

Setting the Number of Data Rows For Each Page in an AHTML Report Request

How to:

You can use the LINES-PER-PAGE StyleSheet attribute in an AHTML report request to set the number of data rows to display on each page in the report output.

Syntax: How to Set the Number of Data Rows For Each Page in an AHTML Report Request

To control the number of data rows to display on each page in the report output, use the following StyleSheet syntax:

TYPE=REPORT, LINES-PER-PAGE={n|UNLIMITED},$

where:

n

Specifies the number of data rows to display on each page. The default value is 57 rows.

UNLIMITED

Specifies that you want to show all the results on one page.

Note:

  • In an AHTML report request, using the following SET command, you will see the same number of data rows as the LINES-PER-PAGE StyleSheet option:
    ON TABLE SET LINES {n|UNLIMITED}
  • In an HTML report request, using either the LINES-PER-PAGE StyleSheet option or the SET LINES command, you will see the number of lines, as opposed to the number of data rows.

Example: Setting the Number of Data Rows For Each Report Page

The following example uses the default WebFOCUS StyleSheet and displays 20 data rows on each page of the report output.

TABLE FILE GGSALES
HEADING
"Sales Report"
SUM UNITS DOLLARS
BY CATEGORY BY PRODUCT BY DATE NOPRINT
WHERE DATE GE 19960101 AND DATE LE 19960401
ON TABLE PCHOLD FORMAT AHTML
ON TABLE SET STYLE *
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,$
TYPE=REPORT, GRID=OFF, LINES-PER-PAGE = 20, $
ENDSTYLE
END

The following image shows the output for the first page.

The following image shows the output for the second page.