Entering content frame

Passing Data Automatically Locate the document in its SAP Library structure

The system passes data to programs automatically using the system fields that it fills for each interactive event. For an overview of the relevant system fields, see Detail Lists.

System fields provide you with information about the list index, the position of the list in the output window, and the cursor position. The only system field that contains the contents of the selected line is sy-lisel.

The example below demonstrates how the system fills these system fields during interactive events.

Example

REPORT demo_list_system_fields NO STANDARD PAGE HEADING
                                LINE-COUNT 12 LINE-SIZE 40.

DATA: l TYPE i, t(1) TYPE c.

DO 100 TIMES.
  WRITE: / 'Loop Pass:', sy-index.
ENDDO.

TOP-OF-PAGE.

  WRITE: 'Basic List, Page', sy-pagno.
  ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.

WRITE 'Secondary List'.
  ULINE.

AT LINE-SELECTION.

  DESCRIBE FIELD sy-lisel LENGTH l IN CHARACTER MODE
                          TYPE t.

  WRITE: 'SY-LSIND:', sy-lsind,
       / 'SY-LISTI:', sy-listi,
       / 'SY-LILLI:', sy-lilli,
       / 'SY-CUROW:', sy-curow,
       / 'SY-CUCOL:', sy-cucol,
       / 'SY-CPAGE:', sy-cpage,
       / 'SY-STARO:', sy-staro,
       / 'SY-LISEL:', 'Length =', l, 'Type =', t,
       /  sy-lisel.

This program creates a list of ten pages. When you run the program, you can place the cursor within the basic list and create a detail list by choosing Choose. This displays the contents of the system fields.

sy-lsind is the index of the current list; sy-listi is the index of the previous list. sy-lilli is the number of the selected line in the overall list; sy-curow is the position of the selected line on the screen. sy-cucol is the position of the cursor  in the dialog box. This position is larger by one than the corresponding unscrolled list column. sy-cpage is the uppermost displayed page of the list. sy-staro is the number of the uppermost actual list line that is displayed on the uppermost page. Here, the page header is not counted. sy-cpage and sy-staro are independent of the cursor position. For sy-lisel, the program displays length, data type, and contents. The length of sy-lisel is always 255, regardless of the width of the list.

Using sy-lisel

The system field sy-lisel is a type C field with length 255. Although it contains the selected line, it is only of limited use for passing the values of single fields, since it is a character string. To process certain parts of sy-lisel, you must specify the corresponding offsets.

For value transfer, therefore, it is more recommendable to use one of the methods described in Passing Data by Program Statements. sy-lisel, on the other hand, is more suitable for laying out the headings of detail list, or for checking whether a selected line is a blank line or an underlining line.

Example

REPORT demo_list_sy_lisel NO STANDARD PAGE HEADING.

DATA num TYPE i.

SKIP.
WRITE 'List of Square Numbers between One and Hundred'.
SKIP.
WRITE 'List of Cubic Numbers between One and Hundred'.

TOP-OF-PAGE.
WRITE 'Choose a line!'.
  ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.
  WRITE sy-lisel.
  ULINE.

AT LINE-SELECTION.
  IF sy-lisel(4) = 'List'.
    CASE sy-lilli.
WHEN 4.
    DO 100 TIMES.
          num = sy-index ** 2.
          WRITE: / sy-index, num.
        ENDDO.
WHEN 6.
    DO 100 TIMES.
          num = sy-index ** 3.
          WRITE: / sy-index, num.
        ENDDO.
  ENDCASE.
  ENDIF.

When you start the program, a list appears on which two lines can be selected.

If you choose the top line, a list of square numbers is displayed. If you select the lower line on the basic list, the list of cubic numbers appears.

The content of the selected line becomes the header of the detail list. The IFstatement uses the first four characters of sy-lisel to make sure that only valid lines are selected. Due to the logical conditions of the processing block following AT LINE-SELECTION, the system does not display any more information if you choose a line on the detail list.

 

 

Leaving content frame