cancel
Showing results for 
Search instead for 
Did you mean: 

Editing selected row in a table?

Former Member
0 Kudos

Hi Experts,

How can we edit selected record or row in a table? can any one give me some suggetions?

Thanks and Regards,

kris.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

sorry Table Column read_only property has to binded to 'SET_READ_ONLY' attribute.

Say you had 3 columns all 3 columns read_only property has to be binded 'SET_READ_ONLY' attribute

With Regards,

Shridhar

Former Member
0 Kudos

Hi Sridhar,

Actually, i want display data in a table, i am using service call to get data, by defalut coloumns are text views, i changes some cols as input some as dropdownbykey some as text view. when i am trying to test all are in edit mode. but my requirement is first ineed to display in edit mode, when user select a record and click on update button, that record need to convert in edit mode so that user can update data.? Help me please.

Thanks

kris.

Former Member
0 Kudos

hi,

As shridhar suggested , create a attribute (say set_read_only) of type abap_bool and bind it to the read_only property of all columns.

Then in your handler of edit button , get the selected element using GET_LEAD_SELECTION() and then set the attribute "read_only" for that element to abap_false.This will make all columns editable.

Thanks,

Aditya.

Former Member
0 Kudos

Hi,

I guess your table read_only property is not set. So in layout set the read_only property of table.

Then when user selects the row and clicks Update button, here

1. You need to set the read_only property as abap_false .

2. Choose the input field or dropdown or any UI you want as selected cell variant.

With Regards,

Shridhar

former_member222068
Active Participant
0 Kudos

Hi



METHOD onactionupdate .

  DATA lo_nd_is_data TYPE REF TO if_wd_context_node.

  DATA lo_el_is_data TYPE REF TO if_wd_context_element.
  DATA ls_is_data TYPE wd_this->element_is_data.
  DATA : lv_name TYPE wd_this->element_is_data-name,
         lv_sal TYPE wd_this->element_is_data-sal,
         lv_per TYPE wd_this->element_is_data-percent,
         lv_empno   TYPE wd_this->element_is_data-empno,
         wa_data TYPE ysg_demo,
         it_data TYPE STANDARD TABLE OF ysg_demo.


*   navigate from <CONTEXT> to <IS_DATA> via lead selection
  lo_nd_is_data = wd_context->path_get_node( path = `YSG_DEMO.CHANGING.IS_DATA` ).

*   get element via lead selection
  lo_el_is_data = lo_nd_is_data->get_element( ).

  lo_nd_is_data->get_lead_selection( ).

  lo_el_is_data->get_attribute( EXPORTING name =  `EMPNO`   IMPORTING value = lv_empno ).
  lo_el_is_data->get_attribute( EXPORTING name =  `NAME`    IMPORTING value = lv_name ).
  lo_el_is_data->get_attribute( EXPORTING name =  `SAL`  IMPORTING value = lv_sal ).
  lo_el_is_data->get_attribute( EXPORTING name =  `PERCENT` IMPORTING value = lv_per ).


  MOVE :  lv_empno TO  wa_data-empno,
    lv_name TO wa_data-name,
    lv_sal TO wa_data-sal,
    lv_per TO wa_data-percent.

*  APPEND wa_data TO it_data.

  MODIFY ysg_demo FROM wa_data.

ENDMETHOD.

Note: First get data to your table and take button say 'UPDATE' and implement the code on action of a button.Hope this will help you.

Regards

Sankar

Edited by: sankar.cgsl on Sep 15, 2010 11:00 AM

Former Member
0 Kudos

Hi Sankar,

Thanks for your reply.

i am having records in a table, all are in display mode, when user select a record and click on "Edit" button, that record should be in edit mode, so that user can modify record and update to database.. this is the requirement? any help.

Thanks,

kriss.

Former Member
0 Kudos

Hi,

Please maintain the attribute 'set_read_only' along with other attributes table. Bind this attribute to the table read_only property.

Say User clicks on 'Edit' button then get the row selected using get_lead_Selection method of node and set the attribute of 'set_read_only' as abap_false. This will make the row editable.

                      • ths should be written in edit action method ************

element = node->get_lead_selection( ).

element->set_attribute(

exporting

name = 'SET_READ_ONLY'

value = abap_false ).

Note : Table columns read_only property has to be binded to set_read_only attribute.

With Regards,

Shridhar

former_member222068
Active Participant
0 Kudos

This message was moderated.

Former Member
0 Kudos

Kris,

data lo_nd_ type ref to if_wd_context_node.

data lo_el type ref to if_wd_context_element.

lo_nd = wd_context->get_child_node( name = wd_this->wdctx_node_name).

call method lo_nd->get_lead_selection

receiving

element = lo_el

lo_el holds the value of the selected row

Thanks

Bala Duvvuri

.