Entering content framePassing Data by Program Statements Locate the document in its SAP Library structure

To pass individual output fields or additional information from a line to the corresponding processing block during an interactive event, use these statements:

The HIDE statement is one of the fundamental statements for interactive reporting. You use the HIDE technique when creating a basic list. It defines the information that can be passed to subsequent detail lists.

Use the statements READ LINE and READ CURRENT LINE to read data from the lines of existing list levels. These statements are closely connected to the HIDE technique.

Use the statements GET CURSOR FIELD and GET CURSOR LINE to pass the output field or output line on which the cursor was positioned during the interactive event to the ABAP program.

The DESCRIBE LIST statement allows you to read certain list attributes, such as the number of lines or pages, into program variables.

The following sections describe these statements in more detail:

The HIDE Technique

You use the HIDE technique while creating a list level to store line-specific information for later use. To do so, use the HIDE statement as follows:

HIDE <f>.

This statement places the contents of the variable <f> for the current output line (system field SY-LINNO) into the HIDE area. The variable <f> must not necessarily appear on the current line.

To make your program more readable, always place the HIDE statement directly after the output statement for the variable <f> or after the last output statement for the current line.

As soon as the user selects a line for which you stored HIDE fields, the system fills the variables in the program with the values stored. A line can be selected

For each interactive event, the HIDE fields of the line on which the cursor is positioned during the event are filled with the stored values.

You can think of the HIDE area as a table, in which the system stores the names and values of all HIDE fields for each list and line number. As soon as they are needed, the system reads the values from the table.

The example below presents some of the essential features of interactive reporting. The basic list contains summarized information. By means of the HIDE technique, each detail list contains more details.

Example

The following program is connected to the logical database F1S.

REPORT demo_list_hide NO STANDARD PAGE HEADING.

TABLES: spfli, sbook.

DATA: num TYPE i,
      dat TYPE d.

START-OF-SELECTION.
  num = 0.
  SET PF-STATUS 'FLIGHT'.

GET spfli.
  num = num + 1.
  WRITE: / spfli-carrid, spfli-connid,
           spfli-cityfrom, spfli-cityto.
  HIDE:    spfli-carrid, spfli-connid, num.

END-OF-SELECTION.
  CLEAR num.

TOP-OF-PAGE.
  WRITE 'List of Flights'.
  ULINE.
  WRITE 'CA  CONN FROM                 TO'.
  ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.
  CASE sy-pfkey.
    WHEN 'BOOKING'.
      WRITE sy-lisel.
      ULINE.
    WHEN 'WIND'.
      WRITE:  'Booking', sbook-bookid,
           /  'Date   ', sbook-fldate.
      ULINE.
  ENDCASE.

AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN 'SELE'.
      IF num NE 0.
        SET PF-STATUS 'BOOKING'.
        CLEAR dat.
        SELECT * FROM sbook WHERE carrid = spfli-carrid
                            AND   connid = spfli-connid.
          IF sbook-fldate NE dat.
            dat = sbook-fldate.
            SKIP.
            WRITE / sbook-fldate.
            POSITION 16.
          ELSE.
            NEW-LINE.
            POSITION 16.
          ENDIF.
          WRITE sbook-bookid.
          HIDE: sbook-bookid, sbook-fldate, sbook-custtype,
                sbook-smoker, sbook-luggweight, sbook-class.
        ENDSELECT.
        IF sy-subrc NE 0.
          WRITE / 'No bookings for this flight'.
        ENDIF.
        num = 0.
        CLEAR sbook-bookid.
      ENDIF.
    WHEN 'INFO'.
      IF NOT sbook-bookid IS INITIAL.
        SET PF-STATUS 'WIND'.
        SET TITLEBAR 'BKI'.
        WINDOW STARTING AT 30 5 ENDING AT  60 10.
        WRITE: 'Customer type   :', sbook-custtype,
             / 'Smoker          :', sbook-smoker,
             / 'Luggage weight :', sbook-luggweight UNIT 'KG',
             / 'Class           :', sbook-class.
      ENDIF.
  ENDCASE.

At the event START-OF-SELECTION, the system sets the status FLIGHT for the basic list. In status FLIGHT, function code SELE (text SELECT) is assigned to function key F2 and to a pushbutton. So the event AT USER-COMMAND is triggered if the user double-clicks, presses F2, or chooses the pushbutton SELECT.

The three fields SPFLI-CARRID, SPFLI-CONNID, and NUM are stored in the HIDE area while creating the basic list. After selecting a line, the system displays the detail list defined in the AT USER-COMMAND event for function code SELE. In the AT USER-COMMAND event, the system refills all fields of the selected line that were stored in the HIDE area. You use NUM to check whether the user selected a line from the actual list. The detail list has status BOOKING, where F2 is assigned to function code INFO (text: Booking Information). The detail list presents data that the program selected by means of the HIDE fields of the basic list. For each list line displayed, the system stores additional information in the HIDE area.

If the user selects a line of the detail list, the system displays the "hidden" information in a dialog box with the status WIND. The status has the type Dialog box, and contains the proposed functions for a list status. The program uses SBOOK-BOOKID to check whether the user selected a valid line.

The program itself sets all page headers and the title bar of the dialog box.

Reading Lines from Lists

All of the lists generated by a single program are stored internally in the system. You can therefore access any list in a program that was created for the same screen and that has not yet been deleted by returning to a lower list level. To read lines, use the statements READ LINE and READ CURRENT LINE.

To read a line from a list after an interactive list event, use the READ LINE statement:

READ LINE <lin> [INDEX <idx>]
[FIELD VALUE <f1> [INTO <g 1>] ... <f n> [INTO <g n>]]
[OF CURRENT PAGE|OF PAGE <p>].

The statement without any options stores the contents of line <lin> from the list on which the event was triggered (index SY-LILLI) in the SY-LISEL system field and fills all HIDE information stored for this line back into the corresponding fields. As far as SY-LISEL and the HIDE area are concerned, READ LINE has the same effect as an interactive line selection.

If the selected line <lin> exists, the system sets SY-SUBRC to 0, otherwise to 4.

The options have the following effects:

The system reads the information for line <lin> from the list of level <idx>.

The system interprets the output values of the variables <f i > in line <lin> as character strings and places them either into the same fields <f i > or, when using INTO, into the fields <g i >.When refilling the fields, the system applies the conversion rules.

Fields that do not appear in a line do not affect the target field. If a field appears several times in a line, the system uses only the first one.

The system transports the field contents using the output format, that is, including all formatting characters. This may cause problems, such as converting editing characters to decimal characters or other incompatible cases.

You use this option mainly to process user entries in list fields that accept input, since you cannot use the HIDE technique in this case.

With this option, <lin> is not the number of the line of the entire list, but the number of the line of the currently displayed page of the addressed list. The system field SY-CPAGE stores the corresponding page number.

With this option, <lin> is not the number of the line of the entire list, but the number of a line on page <p> of the addressed list.

This statement reads a line twice in succession. To do this, you use the READ CURRENT LINE statement in your program:

READ CURRENT LINE [FIELD VALUE <f1> [INTO <g 1>] ...].

This statement reads a line read before by an interactive event ( F2 ) or by READ LINE. The FIELD VALUE option is the same as for READ LINE.

This allows you to fill fields in the same line using values from the program.

Example

The following program is connected to the logical database F1S.

REPORT demo_list_read_line NO STANDARD PAGE HEADING.

TABLES: sflight.

DATA: box(1) TYPE c, lines TYPE i, free TYPE i.

START-OF-SELECTION.
  SET PF-STATUS 'CHECK'.

GET sflight.
  WRITE: box AS CHECKBOX, sflight-fldate.
  HIDE: sflight-fldate, sflight-carrid, sflight-connid,
        sflight-seatsmax, sflight-seatsocc.

END-OF-SELECTION.
  lines = sy-linno - 1.

TOP-OF-PAGE.
  WRITE: 'List of flight dates'.
  ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.
  WRITE:  'Date:', sflight-fldate.
  ULINE.

AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN 'READ'.
      box = space.
      SET PF-STATUS 'CHECK' EXCLUDING 'READ'.
      DO lines TIMES.
        READ LINE sy-index FIELD VALUE box.
        IF box = 'X'.
          free = sflight-seatsmax - sflight-seatsocc.
          IF free > 0.
            NEW-PAGE.
            WRITE: 'Company:', sflight-carrid,
                   'Connection: ',sflight-connid,
                 / 'Number of free seats:', free.
          ENDIF.
        ENDIF.
      ENDDO.
  ENDCASE.

After the selection screen has been processed, a basic list appears, on which the user can select checkboxes. The user-defined page header for the basic list uses the parameters CITY_FR and CITY_TO. The parameters are defined in the logical database F1S.

The program uses the status CHECK, where the user-defined function code READ (text Read Lines) is assigned to function key F5 and to a pushbutton in the application toolbar. The corresponding user action triggers the AT USER-COMMAND event. The system now reads all lines of the basic list using READ LINE in a DO loop. For each line, it fills the corresponding fields with all values previously stored in the HIDE area. By means of the FIELD VALUE option, the system in addition reads the checkbox BOX. If seats are still free, the system writes the company, the connection, and the number of free seats into a detail list for each line in which the checkbox was selected.

The system starts a new page with an individual page header for each output. On the detail list, the function code READ is deactivated using the EXCLUDING addition of the SET PF-STATUS statement.

After returning from the detail list, the checkboxes are still filled.

Reading Lists at the Cursor Position

To retrieve information about the current cursor position in an interactive event, use the GET CURSOR statement. You can retrieve information either about the current field or the current line.

For field information, use this syntax:

GET CURSOR FIELD <f> [OFFSET <off>] [LINE <lin>]
[VALUE <val>] [LENGTH <len>].

This statement transfers the name of the field on which the cursor is positioned during a user action into the variable <f>. If the cursor is on a field, the system sets SY-SUBRC to 0, otherwise to 4.

The system transports the names of global variables, constants, field symbols, or reference parameters of subroutines. For literals, local fields, and VALUE parameters of subroutines, the system sets SY-SUBRC to 0, but transfers SPACE as the name.

The options have the following effects:

The field <off> contains the position of the cursor within the field. If the cursor is on the first column, <off> = 0.

The field <lin> contains the number of the list line on which the cursor is positioned (SY-LILLI).

The field <val> contains the character string output representation of the field on which the cursor is positioned. The representation includes formatting characters.

The field <len> contains the output length of the field on which the cursor is positioned.

For field information, use this syntax:

GET CURSOR LINE <lin> [OFFSET <off>] [VALUE <val>] [LENGTH <len>].

This statement transfers the number of the line on which the cursor is positioned during a user action into the variable <lin>. If the cursor is on a list line, the system sets SY-SUBRC to 0, otherwise to 4. You can use this statement to prevent the user from selecting invalid lines.

The options have the following effects:

The field <off> contains the position of the cursor within the list line. If the cursor is on the first column, <off> = 0.

The field <val> contains the character string output representation of the line on which the cursor is positioned. The representation includes formatting characters.

The field <len> contains the output length of the line on which the cursor is positioned.

Example

REPORT SAPMZTST NO STANDARD PAGE HEADING LINE-SIZE 40.

DATA: HOTSPOT(10) VALUE 'Click me!',
      F(10), OFF TYPE I, LIN TYPE I, VAL(40), LEN TYPE I.

FIELD-SYMBOLS <FS>.
ASSIGN HOTSPOT TO <FS>.
WRITE 'Demonstration of GET CURSOR statement'.
SKIP TO LINE 4.
POSITION 20.
WRITE <FS> HOTSPOT COLOR 5 INVERSE ON.

AT LINE-SELECTION.
  WINDOW STARTING AT 5 6 ENDING AT 45 20.
  GET CURSOR FIELD F OFFSET OFF
             LINE LIN VALUE VAL LENGTH LEN.
  WRITE: 'Result of GET CURSOR FIELD: '.
  ULINE AT /(28).
  WRITE: / 'Field: ', F,
         / 'Offset:', OFF,
         / 'Line:  ', LIN,
         / 'Value: ', (10) VAL,
         / 'Length:', LEN.
  SKIP.
  GET CURSOR LINE LIN OFFSET OFF VALUE VAL LENGTH LEN.
  WRITE: 'Result of GET CURSOR LINE: '.
  ULINE AT /(27).
  WRITE: / 'Offset:', OFF,
         / 'Value: ', VAL,
         / 'Length:', LEN.

In this program, the HOTSPOT field is assigned to the field symbol <FS> and displayed as hotspot on the output screen. If the user positions the cursor on a list line and selects it, a dialog box appears containing the results of the GET CURSOR statements in the AT LINE-SELECTION event.

Note that after GET CURSOR FIELD, the name of the field assigned to the field symbol <FS> is stored in F, and not the name of the field symbol.

Determining the Attributes of Lists

If you need to know the attributes of list levels that are not stored in system variables, you can use the DESCRIBE LIST statement.

To retrieve the number of lines or pages of a list, use:

DESCRIBE LIST NUMBER OF LINES|PAGES <n> [INDEX <idx>].

This statement writes the number of lines or pages of the list level <idx> into the variable <n>. If a list with index <idx> does not exist, the system sets SY-SUBRC unequal to 0, otherwise to 0.

To retrieve the page number for a certain line number, use:

DESCRIBE LIST LINE <lin> PAGE <pag> [INDEX <idx>].

This statement writes for list level <idx> the page number on which the list line number <lin> is found into the variable <pag>. SY-SUBRC is set as follows: If there is no list with the index <idx>, it is 8. If there is no line with number <line>, it is 4. Otherwise, it is 0.

To retrieve the attributes of a certain page, use:

DESCRIBE LIST PAGE <pag> [INDEX <idx>] [<options>]

This statement retrieves for list level <idx> the attributes specified in <options> for page <pag>. SY-SUBRC is set as follows: If there is no list with the index <idx>, it is 8. If there is no page with number <pag>, it is 4. Otherwise, it is 0.

The <options> of the statement are:

writes the page width into the variable <col>.

writes the page length into the variable <len>.

writes the number of displayed lines into the variable <lin>.

writes the absolute number of the first line into the variable <lin1>.

writes the number of page header lines into the variable <top>.

writes the number of list header lines of the standard page header into the variable <ttl>.

writes the number of column header lines of the standard page header into the variable <head>.

writes the number of page footer lines into the variable <end>.

Use DESCRIBE LIST for completed lists only, since for lists in creation (index is SY-LSIND) some attributes are not up to date.

Example

REPORT demo_list_describe_list NO STANDARD PAGE HEADING
                               LINE-SIZE 40 LINE-COUNT 5(1).

DATA: lin TYPE i, pag TYPE i,
      col TYPE i, len TYPE i, lin1 TYPE i,
      top TYPE i, tit TYPE i, head TYPE i, end TYPE i.

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

TOP-OF-PAGE.
  WRITE 'Demonstration of DESCRIBE LIST statement'.
  ULINE.

END-OF-PAGE.
  ULINE.

AT LINE-SELECTION.
  NEW-PAGE LINE-COUNT 0.
  WINDOW STARTING AT 1 13 ENDING AT 40 25.
  DESCRIBE LIST: NUMBER OF LINES lin INDEX 0,
                 NUMBER OF PAGES pag INDEX 0.
  WRITE: 'Results of DESCRIBE LIST: '.
  ULINE AT /(25).
  WRITE: / 'Lines: ', lin,
         / 'Pages: ', pag.
  SKIP.
  DESCRIBE LIST LINE sy-lilli PAGE pag INDEX 0.
  WRITE: / 'Line', (1) sy-lilli, 'is on page', (1) pag.
  SKIP.
  DESCRIBE LIST PAGE pag INDEX 0 LINE-SIZE   col
                                 LINE-COUNT  len
                                 LINES       lin
                                 FIRST-LINE  lin1
                                 TOP-LINES   top
                                 TITLE-LINES tit
                                 HEAD-LINES  head
                                 END-LINES   end.
  WRITE: 'Properties of Page', (1) pag, ':',
       / 'Width:       ',  col,
       / 'Length:      ',  len,
       / 'Lines:       ',  lin,
       / 'First Line:  ',  lin1,
       / 'Page Header: ',  top,
       / 'Title Lines: ',  tit,
       / 'Header Lines:',  head,
       / 'Footer Lines:',  end.

This program creates a two-page list of five lines per page. Two lines are used for the self-defined page header and one line for the page footer. If the user selects a line, a dialog box appears containing the list attributes.

While creating the secondary list, all variants of the DESCRIBE LIST statement apply to the basic list. The system displays the results in the dialog window. The lines and pages to be described are addressed dynamically using SY-LILLI.

Leaving content frame