Well, I’m still learning things about the Web Dynpro version of the ALV Table. In this post, I’m going to about how to make an editable ALV Table within ABAP Web Dynpro. So far, I’ve talked about how to make the table, and now it’s time for a little more advanced stuff.
Here’s some simple code to handle this aspect:
data: l_ref_cmp_usage type ref to if_wd_component_usage. " Instantiate the ALV usage l_ref_cmp_usage = wd_This->wd_CpUse_My_Alv( ). if l_ref_cmp_usage->has_active_component( ) is initial. l_ref_cmp_usage->create_component( ). endif. " Get reference to the model DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE . l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_My_Alv( ). data: lr_config type ref to Cl_Salv_Wd_Config_Table. lr_config = l_ref_INTERFACECONTROLLER->Get_Model( ). |" Set read only mode to false (and display edit toolbar) lr_config->if_salv_wd_table_settings~set_read_only( abap_false ). data: lr_table_settings type ref to if_salv_wd_table_settings. lr_table_settings ?= lr_config. lr_table_settings->set_read_only( abap_false ). Now, this is only the first half of the equation. By default, every column is a text view within the table. In order to have anything to edit, you'll need to change certain columns to be a different editor. If you want to set something to say a checkbox, this is how you'd go about doing it.
data: lr_column_settings TYPE REF TO if_salv_wd_column_settings, lt_columns TYPE salv_wd_t_column_ref, ls_columns TYPE salv_wd_s_column_ref, lr_checkbox TYPE REF TO cl_salv_wd_uie_checkbox. " Embed the UI elements within the ALV lr_column_settings ?= lr_config. lt_columns = lr_column_settings->get_columns( ). " Embed a checkbox within the column APPROVE LOOP AT lt_columns into ls_columns. CASE ls_columns-id. WHEN 'APPROVE'. CREATE OBJECT lr_checkbox1 EXPORTING checked_fieldname = ls_columns-id. ls_columns-r_column->set_cell_editor( lr_checkbox ). FREE lr_checkbox. ENDCASE. ENDLOOP. While there are a lot of ways to handle this, this is the most straightforward. As always, thanks for reading,As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike