Entering content frameModifying List Lines Locate the document in its SAP Library structure

To modify the lines of a completed list from within the program, use the MODIFY LINE statement. There are two ways to specify the line you want to modify:

MODIFY LINE <n> [INDEX <idx>|OF CURRENT PAGE|OF PAGE <p>]
                [<modifications>].

Without the first line of options, this statement modifies line <n> of the list on which an interactive event occurred (index SY-LISTI). With the options of the first line, you can specify the line you want to modify as follows:

– Use INDEX <idx> to specify line <n> of the list level with the index <idx>.

– Use OF CURRENT PAGE to specify line <n> of the currently displayed page (page number SY-CPAGE) .

– Use OF PAGE <p> to specify line <n> of page <p>.

You can refer to the line most recently read:

MODIFY CURRENT LINE [<modifications>].

This statement modifies the line most recently read by means of line selection ( F2 ) or of the READ LINE statement.

Without the option <modifications>, the above statements fill the current contents of the SY-LISEL system field into the specified line. The line's HIDE area is overwritten by the current values of the corresponding fields. However, this does not influence the displayed values.

If the system succeeded in modifying the specified line, it sets SY-SUBRC to 0, otherwise to a value unequal to 0.

Apart from the ones described above, the option <modifications> contains several other possibilities to modify the line.

Modifying Line Formatting

To modify the formatting of the line you want to change, use the option LINE FORMAT of the MODIFY statement as follows:

MODIFY ... LINE FORMAT <option1> <option 2> ... .

This statement sets the output format of the entire modified line according to the format specified with <option i >. You can specify the same format options as for the FORMAT statement.

Modifying Field Contents

To explicitly modify the contents of fields in the line you want to change, use the option FIELD VALUE of the MODIFY statement:

MODIFY ... FIELD VALUE <f1> [FROM <g 1>] <f 2> [FROM <g 2>] ... .

This statement overwrites the contents of the fields <f i > in the list line with the current contents of the fields <f i > or <g i >. If necessary, the system converts the field type to type C.

If a field <f i > occurs more than once in the line, the system modifies only the first. If a field <f i > does not occur in the line at all, the system ignores the option.

The system modifies existing fields <f i > regardless of the current contents you write from SY-LISEL into the line. If you made changes to the line at the output position of a field <f i > using SY-LISEL, the FIELD VALUE option overwrites them.

Changing Field Formatting

To modify the formatting of fields in the line you want to change, use the option FIELD FORMAT of the MODIFY statement as follows:

MODIFY ... FIELD FORMAT <f1> <options 1> <f 2> <options 2> ... .

This statement sets the output format of the fields <f i > occurring in the line according to the format specified in <options i >. You can specify formats from the FORMAT statement in <options i >.

The option FIELD FORMAT overwrites the specifications of the LINE FORMAT option for the corresponding field(s). If a field <f i > occurs more than once in the line, the system modifies only the first. If a field <f i > does not occur in the line at all, the system ignores the option.

Examples

Example

Example of line formatting.

REPORT demo_list_modify_line_format LINE-SIZE 40
                                    NO STANDARD PAGE HEADING.

DATA c TYPE i VALUE 1.

WRITE 'Select line to modify the background'.

AT LINE-SELECTION.
  IF c = 8.
    c = 0.
  ENDIF.
  MODIFY CURRENT LINE LINE FORMAT COLOR = c.
  ADD 1 TO c.

This program creates an output line whose background color the user can change by selecting the line again and again:

Example

Example for field contents.

REPORT demo_list_modify_field_value LINE-SIZE 40
                                    NO STANDARD PAGE HEADING.

DATA c TYPE i.

WRITE: '   Number of selections:', (2) c.

AT LINE-SELECTION.
  ADD 1 TO c.
  sy-lisel(2) = '**'.
  MODIFY CURRENT LINE FIELD VALUE c.

This program creates an output line, in which the user can modify the field C by selecting the line. At the same time, the system overwrites the first two characters of the line with two asterisks '**' due to the modification of SY-LISEL.

Example

Example for field formatting.

REPORT demo_list_modify_field_format NO STANDARD PAGE HEADING.

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

SET PF-STATUS 'CHECK'.

DO 5 TIMES.
  num = sy-index.
  WRITE: / box AS CHECKBOX, 'Line', num.
  HIDE: box, num.
ENDDO.
lines = sy-linno.

TOP-OF-PAGE.
  WRITE  'Select some checkboxes'.
  ULINE.

AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN 'READ'.
      SET PF-STATUS 'CHECK' EXCLUDING 'READ'.
      box = space.
      DO lines TIMES.
        READ LINE sy-index FIELD VALUE box.
        IF box = 'X'.
          WRITE: / 'Line', num, 'was selected'.
          box = space.
          MODIFY LINE sy-index
                      FIELD VALUE  box
                      FIELD FORMAT box INPUT OFF
                                   num COLOR 6 INVERSE ON.
        ENDIF.
      ENDDO.
  ENDCASE.

This program creates a basic list with the status CHECK. In the status CHECK, function code READ (text Read Lines) is assigned to function key F5 and to a pushbutton. The user can mark checkboxes and then choose Read Lines.

In the AT USER-COMMAND event, the system reads the lines of the list using READ LINE. It continues processing the selected lines on a secondary list. When returning to the basic list, the system deletes the marks in the checkboxes of the selected lines using MODIFY LINE and sets the format INPUT OFF to the checkboxes. In addition, it changes the format of field NUM.

The user can now mark only those lines that have not yet been changed.

Leaving content frame