Entering content frame

Programming 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

        ends the current page. All other output appears on a new page.

        only starts a new page if output is written to the current page as well as to the new page after NEW-PAGE. The system then increases the sy-pagno system field by one. You cannot produce empty pages.

        does not trigger the END-OF-PAGE event. This means that the system does not output a page footer even if one is defined.

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 nfree 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 REPORTstatement 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 DOloop 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