READ - Reading a Line from a List

Variants:

1. READ LINE line.

2. READ LINE line OF CURRENT PAGE.

3. READ LINE line OF PAGE pag.

4. READ CURRENT LINE.

Variant 1

READ LINE line.

Extras:

1. ... INDEX idx

2. ... FIELD VALUE f1 INTO g1
                      ...
                   fn INTO gn


3. ... LINE VALUE INTO wa

Effect

Reads line number line of the list, usually after a line selection ( AT LINE-SELECTION, AT PFxx, AT USER-COMMAND).
The line is placed in the field SY-LISEL, and all 'hidden' information (HIDE) is automatically placed into its original fields.
The output format of the line read is set for all subsequent MODIFY LINE and WRITE statements.
You can change the contents of format of the list line using MODIFY LINE with the appropriate additinos.


The Return Code is set as follows:

SY-SUBRC = 0:
Line exists
SY-SUBRC <> 0:
Line does not exist

Addition 1

... INDEX idx

Effect

Reads the line from the list with level idx (0, 1, 2...) where more than one list level exists.

Addition 2

... FIELD VALUE f1 INTO g1                    ...
                fn INTO gn


Effect

The contents of the fields f1, f2, ... are transported from the list line to the fields g1, g2, ... . (The field contents in the list line always have type C. The system converts types as in the MOVE statement).

Note

All formatting characters in the list output of f1, f2, ... count as field contents. If a field is displayed more than once in a list line, only its first occurrence is copied. If the field, say f2, is not displayed at all in the line, field g2 remains unchanged. You can omit the addition INTO g2 if, for example, the field contents in the original field (f2, for example), are also to be transported back. In other words,

... FIELD VALUE ... f2

has the same meaning as

... FIELD VALUE ... f2 INTO f2

The return value SY-SUBRC is not affected by the FIELD VALUE addition. In other words, it does not depend on whether the chosen list line exists.

Note

The FIELD VALUE addition is specially intended to process the user's input in an input field in a list (see FORMAT, WRITE), since you cannot address input field using HIDE.

Example

Suppose you make a line "selectable" as follows:

DATA MARKFIELD(1) TYPE C.
     ...
WRITE: / MARKFIELD INPUT, 'Text'.

After the line selection, you can use

CLEAR MARKFIELD.
READ LINE SY-CUROW FIELD VALUE MARKFIELD.

to find out in the program whether the user selected the line or not (IF MARKFIELD = SPACE ...).

Addition 3

... LINE VALUE INTO wa

Effect

The entire contents of the selected list line are transported to field wa.

Note

The LINE VALUE addition allows you to place the entire line contents in a user-defined work area, providing an alternative method of accessing the line that is independent of the attributes of the system field SY-LISEL (length of SY-LISEL is 255 characters).

If you need a work area wa that can accommodate lists of any width, use the type SLIST_MAX_LISTLINE from type group SLIST.

Variant 2

READ LINE line OF CURRENT PAGE.

Extras:

As described in READ LINE.

Effect

Similar to the READ LINE line variant. The line number line refers to the current page (system field SY-CPAGE) at the beginning of the current event. Changing the value of SY-CPAGE in the application program has no influence on the display.

Notes

  1. If the list has multiple control levels, the system always works with the control level in which the line was selected.


  2. When you return from the line selection, the system always returns to the last page to be displayed (if you need to scroll, use the SCROLL statement).


Variant 3

READ LINE line OF PAGE pag.


Extras:

As described in READ LINE.

Effect

As in variant 2, except that the system reads from page pag instead of the current page.

Variant 4

READ CURRENT LINE.


Extras:

See additions 2 and 3 of the variant READ LINE line.

Effect

Rereads the last line to be read (by line selection or READ LINE). This is useful in conjunction with the FIELD VALUE addition for retrieving field contents from the selected line in cases where it impossible to use the HIDE area.


Additional help

Reading Lines from Lists