cancel
Showing results for 
Search instead for 
Did you mean: 

Cell Edit/ Row Edit in ALV WDA

Former Member
0 Kudos

Hi Gurus,

I would like to know if it is possible to make a selected row of ALV Data editable in WDA. If yes, please tell me how to go about the same.

Thanks in Advance.

Rajesh.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi rajesh,

Check the below code for your requirement.In my previous post i gave the code how to make all rows are editable.But you want only the selected row is editable.To do this follow below code as it is.

create a context attribute READONLY of type ABAP_BOOL.

Now write the below code in onAction method of lead selection.

Method onActionLeadSelection.

data:node_flights type rref to if_wd_context_node,

lo_el_flights TYPE REF TO if_wd_context_element.

it_flights type if_componentcontroller=>elements_flights,

ls_flights type if_componentcontroller=>element_flights,

v_index type i.

node_flights = wd_context->get_child_node( 'FLIGHTS' ).

lo_el_flights = node_flights->get_element( ).

  • get all declared attributes

  • Here you will get the selected row values into structure

lo_el_flights->get_static_attributes(

IMPORTING

static_attributes = ls_flights ).

CALL METHOD LO_EL_FLIGHTS->GET_INDEX

RECEIVING

MY_INDEX = v_index.

*now populate READONLY value of structure

ls_flights-readonly = abap_false.

*Get the table data

CALL METHOD

NODE_FLIGHTS->GET_STATIC_ATTRIBUTES_TABLE

IMPORTING

TABLE = it_flights.

*now modify the internal table

modify it_flights from ls_flights index v_index transporting readonly.

*Now bind the table to context

CALL METHOD NODE_FLIGHTS->BIND_TABLE

EXPORTING

NEW_ITEMS = it_flights.

*now the below logic is for to make the row input enable.

Note:

l_value is ALV table reference.

*Get the Column to which you want to make editable

data:lr_input type ref to cl_salv_wd_uie_input_field,

l_column1 type ref to cl_salv_wd_column,

lt_columns type salv_wd_t_column_ref,

ls_columns type salv_wd_s_column_ref,

lt_node_info type WDR_CONTEXT_ATTR_INFO_MAP,

ls_node_info type WDR_CONTEXT_ATTRIBUTE_INFO,

lv_tabix type sy-tabix,

lr_info type ref to IF_WD_CONTEXT_NODE_INFO.

types:begin of ty_name,

name type string,

end of ty_name.

data: lt_name type table of ty_name,

ls_name type ty_name.

lr_info = node_flights->get_node_info( ).

lt_node_info = lr_info->get_attributes( ).

loop at lt_node_info into ls_node_info.

ls_name-name = ls_node_info-name.

append ls_name to lt_name.

endloop.

lt_columns =

l_value->if_salv_wd_column_settings~get_columns( ).

loop at lt_columns into ls_columns.

l_column1 = ls_columns-r_column.

lv_tabix = sy-tabix.

read table lt_name into ls_name index lv_tabix.

create object lr_input1

exporting

value_fieldname = ls_name-name.

l_column1->set_cell_editor( value = lr_input1 ).

*To make the first row is editable

lr_input1->set_read_only_fieldname( value = 'READONLY' ).

endloop.

*Set the table Editable

l_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).

*delete column

l_value->if_slav_wd_column_settings~delete_column('READONLY').

EndMethod.

Before you start your coding also check this Article which is written by me for your better understand.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b7...

Former Member
0 Kudos

Hi rajesh,

please check this code.Write the below code in onAction of Lead selection event handler method.

Note:

l_value is ALV table reference.

*Get the Column to which you want to make editable

data:lr_input type ref to cl_salv_wd_uie_input_field,

l_column1 type ref to cl_salv_wd_column,

lt_columns type salv_wd_t_column_ref,

ls_columns type salv_wd_s_column_ref,

lt_node_info type WDR_CONTEXT_ATTR_INFO_MAP,

ls_node_info type WDR_CONTEXT_ATTRIBUTE_INFO,

lv_tabix type sy-tabix,

lr_info type ref to IF_WD_CONTEXT_NODE_INFO.

types:begin of ty_name,

name type string,

end of ty_name.

data: lt_name type table of ty_name,

ls_name type ty_name.

DATA:

node_flights TYPE REF TO if_wd_context_node,

elem_flights TYPE REF TO if_wd_context_element,

stru_flights TYPE if_search=>element_flights .

navigate from <CONTEXT> to <FLIGHTS> via lead selection

node_flights = wd_context->get_child_node( 'FLIGHTS' ).

lr_info = node_flights->get_node_info( ).

lt_node_info = lr_info->get_attributes( ).

loop at lt_node_info into ls_node_info.

ls_name-name = ls_node_info-name.

append ls_name to lt_name.

endloop.

lt_columns =

l_value->if_salv_wd_column_settings~get_columns( ).

*The below logic will make entire table is editable.But you want only the selected row should be editable for that get the selected row data and use this logic to make that particular is editable.

loop at lt_columns into ls_columns.

l_column1 = ls_columns-r_column.

lv_tabix = sy-tabix.

read table lt_name into ls_name index lv_tabix.

create object lr_input1

exporting

value_fieldname = ls_name-name

.

l_column1->set_cell_editor( value = lr_input1 ).

endloop.

*Set the table Editable

l_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).