You are on page 1of 4

DATA : LO_TABLE_SETTINGS TYPE REF TO IF_SALV_WD_TABLE_SETTINGS.

DATA : LR_COLUMN_SETTINGS TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS.


DATA : LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF.
DATA : LS_COLUMNS LIKE LINE OF LT_COLUMNS.
DATA : LR_input TYPE REF TO CL_SALV_WD_UIE_INPUT_FIELD.
DATA : lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lr_header TYPE REF TO cl_salv_wd_header.

" To get the dropdowns displayed Need to set the table to editable by using below statement
LO_CONFIG->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( ABAP_FALSE ).

LO_CONFIG-
>IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_APPEND_ROW_ALLOWED( ABAP_FALSE ).

LO_CONFIG-
>IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_INSERT_ROW_ALLOWED( ABAP_FALSE ).
LO_CONFIG-
>IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_DELETE_ROW_ALLOWED( ABAP_FALSE ).
LO_CONFIG->if_salv_wd_table_settings~set_read_only( abap_false ).

DATA : lr_table_settings TYPE REF TO if_salv_wd_table_settings,


lr_header TYPE REF TO cl_salv_wd_header.
lr_table_settings ?= lv_value.
lr_header = lr_table_settings->get_header( ) .
lr_header->set_text( 'Sales Related List' ).
DATA : lr_button TYPE REF TO cl_salv_wd_fe_button.
CREATE OBJECT lr_button.
lr_button->set_text( 'Delete' ).
DATA : button TYPE REF TO cl_salv_wd_function.
button = lv_value->if_salv_wd_function_settings~create_function( id = 'DELETE' ).
button->set_editor( lr_button ).

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 rows editable 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_ma
ss ).
**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_sta
ndard ).
**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
).
lr_column_left = l_table_left->if_salv_wd_column_settings~get_column( 'the name of column').
lr_column_left->set_fixed_position( cl_wd_abstr_table_column=>e_fixed_position-left)
lr_column_left is type ref to cl_salv_wd_column and l_table_left is type ref to cl_salv_wd_config_table
*Internal table and work area to store all column id and reference
data lt_columns type salv_wd_t_column_ref.
data ls_columns like line of lt_columns.
*column reference
data lr_column type ref to cl_salv_wd_column.
*input field UI Element
data lr_input type ref to cl_salv_wd_uie_input_field.
*Retrieving all column id and reference
call method lv_value->if_salv_wd_column_settings~get_columns
receiving
value = lt_columns.
*Making all columns editable
loop at lt_columns into ls_columns.
*Assigning column reference
lr_column = ls_columns-r_column.
*Creating input field UI Element
create object lr_input
exporting
value_fieldname = ls_columns-id.
*Assigning input field to column to make it as editable
call method lr_column->set_cell_editor
exporting
value = lr_input.
endloop.
*Enabling editing mode in ALV table
lv_value->if_salv_wd_table_settings~set_read_only( abap_false ).

You might also like