ALV: how to disable editable cell and F4 in certain rows only.
I am building a table maintenance front-end with an ALV grid using OOP concept. Certain fields are editable and also have customised search helps assigned to them in the ALV structure defined for the grid. What I want is where I have identified an entry in my database table as being locked by another user, I want to grey the line out on the ALV grid so that the entry cannot be edited and not have f4 input whilst this entry is locked by another user.
I can grey the line out or disable F4 but not both at the same time. If I disable the cells of the row concerned using MC_STYLE_DISABLED, the F4 is still active and will change the contents of the cell concerned via the data_changed event method in CL_GUI_ALV_GRID.
I have used MC_STYLE_DISABLED where I have declared a layout in my table similiar to this:
DATA: BEGIN OF OUTPUT OCCURS 0, FIELD1, FIELD2, ......... STYLE TYPE LVC_T_STYL, LOCK TYPE C. END OF OUTPUT. DATA: ls_celltab TYPE lvc_s_styl. * Where lock identified, field LOCK set to 'X'. .... LOOP AT OUTPUT where lock = 'X'. ls_celltab-fieldname = 'FIELD1'. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. APPEND ls_celltab TO OUTPUT-STYLE. ls_celltab-fieldname = 'FIELD2'. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. APPEND ls_celltab TO OUTPUT-STYLE. ......... ENDIF. append OUTPUT.
I have tried adding MC_STYLE_F4_NO to field LS_CELLTAB-STYLE2 but this does not do both actions atthe same time.
Can anyone suggest what I might be doing wrong or an alternative way around this?
i think you have to ,try debugging it after F4 selection, if it is going to data_changed event then some thing wrong from your code..
i just tried one sample it works well for me. for disable cells it is not doing any thing though F4 is working..for other cells it is taking the value from F4.