cancel
Showing results for 
Search instead for 
Did you mean: 

TO MAKE SINGLE ROW EDITABLE IN WEBDYNPRO ABAP

Former Member
0 Kudos

HI

I WANT TO MAKE A SINGLE ROW EDITABLE IN MY TABLE CONTROL IS IT POSSIBLE?

IF YES THEN HOW?

I KNOW ABOUT READ ONLY FIELDS BUT I DO NOT KNOW HOW TO UTILIZE IT

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

thanks

uday_gubbala2
Active Contributor
0 Kudos

Hi Rajan,

Which particular row of the table do you want to set as editable? That would be important for formulating the way in which you should code.

Suppose you are displaying the data of MARA using a table and want to make editable only rows in which the unit of measurement is equal to "CCM" then you can proceed as below.

Create a context node (say MARA) with desired fields as attributes. (Cardinality 0..n, Selection 0..1, Initialize lead selection) In addition create an attribute (say READONLY) of type WDY_BOOLEAN under the same node (MARA) which you are using for binding to the table.

First of all take all the cell editors of the table as type, "InputField" to make the entire table as editable. Then go to the each cell editor (TABLE_MATNR_EDITOR, TABLE_ERSDA_EDITOR,...) and bind the readOnly property of the cell to the attribute created earlier. (READONLY)

Below is the coding in WDDOINIT through which you set the desired functionality

METHOD wddoinit .
  DATA: lv_node TYPE REF TO if_wd_context_node,
        lt_mara TYPE ig_componentcontroller=>elements_mara,
        wa_mara TYPE ig_componentcontroller=>element_mara.

  SELECT matnr
         ersda
         ernam
         mtart
         matkl
         meins FROM mara INTO CORRESPONDING FIELDS OF TABLE lt_mara
                                 WHERE meins = 'GM' OR meins = 'CCM'.
  SORT lt_mara BY meins.

  lv_node = wd_context->get_child_node( name = wd_this->wdctx_mara ).
  LOOP AT lt_mara INTO wa_mara.
    IF wa_mara-meins = 'GM'.
      wa_mara-readonly = 'X'.
    ELSE.
      wa_mara-readonly = ' '.
    ENDIF.
    MODIFY lt_mara FROM wa_mara TRANSPORTING readonly.
  ENDLOOP.
  lv_node->bind_table( new_items = lt_mara ).
ENDMETHOD.

Regards,

Uday

Former Member
0 Kudos

Hi,

Yes it is possible.Check the below code.

first create an attribute READONLY of type ABAP_BOOL in tyour context node.then populate READONLY attribute for which row you want to make editable.

here i made some cells are editable and some are non editable for a column PRICE of table SFLIGHT.

select * from sflight
  into corresponding fields of table it_flights up to 100 rows.

loop at it_flights into ls_flights .
 if ls_flights-price = '185.00'.
    ls_flights-readonly = abap_true.
 else.
     ls_flights-readonly = abap_false.
endif.
 append ls_flights to it_final.
endloop.

data: obj_table type ref to cl_wd_table,
      lr_column type ref to cl_wd_table_column,
      lr_column1 type ref to cl_wd_table_column,
      lr_input type ref to cl_wd_input_field,
      lr_input1 type ref to cl_wd_input_field.

obj_table ?= view->get_element( 'TABLE1' ).
obj_table->set_visible_row_count( value = 50  ).

lr_column = obj_table->get_column(
               id         = 'TABLE1_PRICE'
*              INDEX      = INDEX
                 ).
lr_input = cl_wd_input_field=>new_input_field(
      bind_value          = 'FLIGHTS.PRICE'
      id                  = 'IP1'
        ).

 lr_input->set_read_only( value = abap_false   ).


lr_input->bind_read_only( path = 'FLIGHTS.READONLY'   ).
*Path means your nodename.attribute name 
lr_column->set_table_cell_editor( the_table_cell_editor = lr_input  ).

In the above code i made for one column.But in your requirement you want to make a single row editable then you use GET_COLUMNS method to read all the columns and assign READONLY attribute to all the columns.

Thanks

Suman