Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Making only particular cell of ALV editable

Hi,

I have a requirement where when the user clicks on an insert button a blank row should get appended to the ALV and only 1 of the cells in this row should be in editable mode. (Also the other rows of the ALV should be in display mode) I tried coding using the LVC_T_STYL properties but I come up with a screen of all non-editable rows. Please help suggest where I am going wrong. My coding is as below:

My internal table is defined as:

DATA: BEGIN OF it_mara OCCURS 1.
           INCLUDE STRUCTURE mara.
DATA:   cellstyles TYPE lvc_t_styl,
             END OF it_mara.

My other important attribute definitions:

data:   ls_cellstyles TYPE lvc_s_styl,
          ls_layout TYPE lvc_s_layo,

In the PAI event for handling the INSERT button I have coded as:

WHEN 'INSERT'.
      APPEND wa_mara TO it_mara. " Appending a blank row to ALV
      DESCRIBE TABLE it_mara LINES lv_count.
      read table it_mara index lv_count. 
      ls_cellstyles-fieldname = 'MATNR'.
      ls_cellstyles-style = cl_gui_alv_grid=>mc_style_enabled. " Setting only MATNR field of the appended row as enabled
      insert ls_cellstyles into table it_mara-cellstyles.

      MODIFY it_mara INDEX lv_count transporting cellstyles.
      o_grid->refresh_table_display( ).

Am also assigning cellstyles to the stylefname attribute of the layout & passing it to the SET_TABLE_FOR_FIRST_DISPLAY.

Regards,

Uday

Not what you were looking for? View more on this topic or Ask a question