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].
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 read by the READ LINE statement.
Apart from the ones described above, the modifications addition contains several other possibilities to modify the line. For more information on this and on the individual additions of the MODIFY LINE statement, refer to the keyword documentation.
Modifying Line Formatting
To modify the formatting of the line you want to change, use the LINEFORMAT addition of the MODIFY statement as follows:
MODIFY ... LINE FORMAT option 1 option 2 ... .
This statement sets the output format of the entire modified line according to the format specified with option 1 option 2 ... 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 FIELD VALUE addition of the MODIFY statement:
MODIFY ... FIELD VALUE f1 [FROM g1] f2 [FROM g2 ] ... .
This statement overwrites the contents of the fields f1 f2 ... in the list line with the current contents of the fields f1 f2 ... and g 1 g2 ... . If necessary, the system converts the field type to type c .
For more information, refer to the keyword documentation.
Modifying Field Formatting
To modify the formatting of fields in the line you want to change, use the FIELD FORMAT addition of the MODIFY statement as follows:
MODIFY ... FIELD FORMAT f1 options1 f2 options2 ... .
This statement sets the output format of the fields f1 f2 ... occurring in the line according to the format specified in options1 options2 ... . You can specify formats from the FORMAT statement in options1 options2 ... .
The option FIELD FORMAT overwrites, field by field, the specifications of the LINE FORMAT addition. If fields f1 f2 ... occur more than once in the line, the system modifies only the first field. If a field f1 f2 ... does not occur in the line at all, the system ignores the addition.
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:
Here is an example of 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 of line 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.