Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  SAP GUI User Dialogs →  Classic Lists →  Event Blocks for Lists →  TOP-OF-PAGE 

Lists, Page Header

The example shows how to define the page header at the TOP-OF-PAGE event.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT demo_list_top_of_page NO STANDARD PAGE HEADING
                             LINE-SIZE 80 LINE-COUNT 7.

DATA: h1(10) TYPE c VALUE '    Number',
      h2(10) TYPE c VALUE '    Square',
      h3(10) TYPE c VALUE '      Cube',
      n1 TYPE i, n2 TYPE i, n3 TYPE i,
      x TYPE i.

TOP-OF-PAGE.

  x = sy-colno + 8.  POSITION x. WRITE h1.
  x = sy-colno + 8.  POSITION x. WRITE h2.
  x = sy-colno + 8.  POSITION x. WRITE h3.
  x = sy-colno + 16. POSITION x. WRITE sy-pagno.
  ULINE.

START-OF-SELECTION.

  DO 10 TIMES.
    n1 = sy-index. n2 = sy-index ** 2. n3 = sy-index ** 3.
    NEW-LINE.
    WRITE: n1 UNDER h1,
           n2 UNDER h2,
           n3 UNDER h3.
  ENDDO.

Description

This program creates a two-page list. In the user-defined page header, column titles are placed in relative position to each other using the system field sy-colno and the POSITION statement. The actual list output is positioned under the fields of the header line using the addition UNDER of the WRITE statement. The line feeds are made using NEW-LINE.

The different output positions of the individual fields result from the ABAP default of representing character strings as left-justified and numeric fields as right-justified. The alignment can be adjusted using the formatting options LEFT-JUSTIFIED, RIGHT-JUSTIFIED, and CENTERED of the WRITE statement (see WRITE - format_options).