cancel
Showing results for 
Search instead for 
Did you mean: 

editing a table

Former Member
0 Kudos

Hi Forum,

I have a table in my view. I want to change it to editable mode in runtime when i click the change pushbutton. Again if i click display pushbutton it should go to non editable mode. How is this possible programmatically. Kindly help me out.

Thanks,

Swapna

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Swapna,

Just create the standard cell editors of the table control as, "Input Fields" instead of the normal 'TextView". (This can be done as follows... When you right click on the table UI element (under ROOTUIELEMENTCONTAINER) & say "Create Binding" you have the, "Standard Cell Editor" & "Standard Property" fields. Set "Standard Cell Editor" to "InputField" & "Standard Property" to "Value") Create a boolean attribute at component controller level & bind it to the readOnly property of the Table. Dont create this attribute under the same node which you are using to bind to your table. This variable value would then stand true for all the cells under this column. So suppose if you have 4 columns in the table then bind all the 4 columns readOnly attribute to the same boolean variable that you have created. Now place a button & create an eventhandler for the same. Now within this method set true & false ( ) values for this boolean attribute to switch between editable & non-editable modes for the table.

If you however create it under the same node which you are using to bind your table then each cell of the column can have different true/false values resulting in different editable features.)Then within the WDDOINIT method you can You will then get the output as how desired.

Consider the code fragment below. It would result in all the fields which have the MEINS value equal to GM as read only & the rest would be editable. Hope this is clear to you now.

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.
    lv_node->bind_structure(  SET_INITIAL_ELEMENTS = ABAP_FALSE
                              new_item = wa_mara ).
  ENDLOOP.
 
  lv_node->bind_table( new_items = lt_mara ).
ENDMETHOD.

Regards,

Uday

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Swapna,

First create all columns with input fields and take one additinal attribute name it like READ_ONLY of type ABAP_BOOL and bind this attribute to read only property of the column.Initially populate the READ_ONLY attribute with value abap_true.So initially all columns are non editable.

Now ONACTION of your button write the below logic.

read the context node and check the READ_ONLY attribute value if it is abap_true then change to abap_false and vice versa.Now your push button will work like a edit/non edit.

also check this forum thread for your reference.

Former Member
0 Kudos

thanks

yesrajkumar
Active Participant
0 Kudos

Hi ,

Try to use the toggle button as a UI element in your view it will meet your requirement.

Thanks,

Rajkumar.S