Hello All,
I also faced similar problem, Most of the posts replies goes out of topic. Just to keep it simple, I would like to categorize it like this.
ALV always creates all the columns as TextView. So common to all, we must change the cell editor of columns to make individual column editable
There are two ways of doing it
Way1: Get object of individual column and set editor to input field
For example i want to make my client column editable in alv (MANDT)
Write below code
data : lr_inp type REF TO cl_salv_wd_uie_input_field.
create OBJECT lr_inp
exporting
value_fieldname = 'MANDT'
.
lv_value->if_salv_wd_column_settings~get_column( 'MANDT' )->set_cell_editor( value = lr_inp ).
Way2: Use standard API to make the cell editor changes to ALV
cl_wsrs_tools_wd_alv_table=>set_table_column( EXPORTING
io_column = <Pass Object of Column>
iv_editor_type = cl_wsrs_tools_wd_alv_table=>co_cell_editor-<choose your editor type like inpu field etc>
iv_read_only = abap_true/abap_false
iv_column_text = <header text>
).
Now comes to making rows editable
Case 1: To keep all the rows as read only use below method of model object
lv_value->if_salv_wd_table_settings~set_read_only( ABAP_TRUE ).
Case 2: When you want all the rowseditable in an ALV and user can enter data wherever they want. Use below two methods of ALV model instance
**Allows mass edit of data
lv_value->if_salv_wd_table_settings~set_edit_mode( IF_SALV_WD_C_TABLE_SETTINGS=>edit_mode_mass ).
**Makes read only mode to false
lv_value->if_salv_wd_table_settings~set_read_only( ABAP_FALSE ).
The advantage is, you don't need to worry about adding additional rows as and when user fills. ALV will automatically adds the rows.
Case 3: When you want only the filled rows to be editable use edit mode as STANDARD
**Allows mass edit of data
lv_value->if_salv_wd_table_settings~set_edit_mode( IF_SALV_WD_C_TABLE_SETTINGS=>edit_mode_standard ).
**Makes read only mode to false
lv_value->if_salv_wd_table_settings~set_read_only( ABAP_FALSE ).
Case 4: When you want entire ALV in disable mode with some specific CELLS only enabled, we need to use additional fields in context of table node. For every table column attribute create another attribute with some name for eg. MANDT i create one more attribute MANDT_R of type WDY_BOOLEAN.
Now set the read only field name for this cell using below API call
cl_wsrs_tools_wd_alv_table=>set_table_column( EXPORTING
io_column = <Pass Object of Column>
iv_editor_type = cl_wsrs_tools_wd_alv_table=>co_cell_editor-<choose your editor type like inpu field etc>
iv_read_only = abap_true/abap_false
iv_column_text = <header text>
iv_readonly_fieldname = 'MANDT_R'
).
Now if you want only this cell to be editable. Use context programming to change the attribute flag value in that particular row to ABAP_FALSE.
Lets say i want to make MANDT cell to be enabled in 3 rd row
data : lo_element TYPE REF TO if_wd_context_Element.
lo_element = wd_context->get_child_node( 'TABLE_NODE_NAME' )->get_element( 3 ).
lo_element->SET_ATTRIBUTE(
Exporting
Name = 'MANDT_R'
Value = ABAP_FALSE
).
Webdynpro ALV is the most flexible control to show and edit mass data, We just need to use the right API.
Hope this helps.
Regards,
Anurag.