Entering content frameProgramming Page Breaks Locate the document in its SAP Library structure

To program unconditional page breaks, use the NEW-PAGE statement.

To program page breaks depending on the number of empty lines left on a page, use the RESERVE statement.

Unconditional Page Break

To trigger a page break during list processing, use the basic form of the NEW-PAGE statement:

Syntax

NEW-PAGE.

This statement

Example

REPORT demo_list_new_page LINE-SIZE 40.

TOP-OF-PAGE.

  WRITE: 'TOP-OF-PAGE', sy-pagno.
  ULINE AT /(17).

START-OF-SELECTION.

  DO 2 TIMES.
    WRITE / 'Loop:'.
    DO 3 TIMES.
      WRITE / sy-index.
    ENDDO.
    NEW-PAGE.
  ENDDO.

This sample program uses both the standard page header whose list header 'Standard Page Header' is defined as text element, and a self-defined page header. Both page headers appear on each page.

This graphic is explained in the accompanying text

The DO loop encounters the NEW-PAGE statement twice, but executes a page break only once. After the second NEW-PAGE statement, no output is available.

Conditional Page Break- Defining a Block of Lines

To execute a page break on the condition that less than a certain number of lines is left on a page, use the RESERVE statement:

Syntax

RESERVE <n> LINES.

This statement triggers a page break if less than <n> free lines are left on the current list page between the last output and the page footer. <n> can be a variable. Before starting a new page, the system processes the END-OF-PAGE event. RESERVE only takes effect if output is written to the subsequent page (the system will not generate an empty page).

The RESERVE statement thus defines a block of lines that must be output as a whole. To find out which additional practical effects a block of lines may have, see Specifying a Relative Position.

Example

REPORT demo_list_reserve LINE-SIZE 40 LINE-COUNT 8(2).

END-OF-PAGE.

  ULINE.

START-OF-SELECTION.

  DO 4 TIMES.
    WRITE / sy-index.
  ENDDO.

  DO 2 TIMES.
    WRITE / sy-index.
  ENDDO.

  RESERVE 3 LINES.
  WRITE: / 'LINE 1',
         / 'LINE 2',
         / 'LINE 3'.

The list header of the standard page header of this sample program is defined as 'Standard Page Header'. The REPORT statement determines the page length to be eight lines. Two of them are used for the standard page header, another two are reserved for the page footer. The page footer consists of a horizontal line and a blank line. Thus, for outputting the actual list, four lines per page remain. The first DO loop fills these four lines. Then the END-OF-PAGE event occurs, after which the system automatically starts a new page. After the second DO loop, the RESERVE statement triggers the END-OF-PAGE event and a page break, since the number of free lines left on the page is less than three. The output appears as follows:

This graphic is explained in the accompanying text

The three lines on page 3 form a block of lines.

Leaving content frame