One of the key advantage of the old ALV Models is that it enables the user to edit the values in the table.
There are two different ways to set the ALV column as editable.
a) Field Catalog
b) SET_READY_FOR_INPUT
a) Field Catalog: The fields such as field name is used to set the column name of the ALV. The field ‘EDIT’ of the field catalog structure must be set to abap_true. Let us look at the following example.
FIELD-SYMBOLS <ls_field_cat> TYPE lvc_s_fcat.
LOOP AT lt_field_cat ASSIGNING <ls_field_cat>.
IF <ls_field_cat>-fieldname = ‘contact_address’.
<ls_field_cat>-edit = abap_true.
ENDIF.
ENDLOOP.
Thus the editing mode of the ALV Grid for the respective columns are activated. The ALV Grid facilitates
additional buttons for editing data.
b) The other way of editing data is through the SET_READY_FOR_INPUT method of the CL_GUI_ALV_GRID class. The editing mode is activated or deactivated through the parameter i_ready_for_input.
For activation:
CALL METHOD lr_gui_alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
For deactivation:
CALL METHOD lr_gui_alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
The data is modified through the above technique. It is much similar to the conventional
DISPLAY <-> CHANGE options of the ABAP Editor.
once the data is edited, it must be saved initially to the internal table. Based on the needs, the data can be saved to the Database table. The method check_changed_data of the class CL_GUI_ALV_GRID is used to check if the data of the ALV Grid has been changed.
DATA lv_alv_changed TYPE c.
CALL METHOD lr_gui_alv_grid->check_changed_data
IMPORTING
c_valid = lv_alv_changed.
The variable lv_alv_changed holds the value ‘X’ or initial. If the data of the grid is changed, then it is ‘X’. If it is not changed, it’s value is INITIAL. Therefore the changes are saved to the Internal table. If it is required, it can also be saved to the Database table.