Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV: how to disable editable cell and F4 in certain rows only.

Former Member
0 Kudos

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?

Many thanks

Regards

Larissa

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Only when I did er_event_data->m_event_handled = c_yes without calling the search help did it work. What was happening was that although the field was disbaled, the contents of that cell where changing if I called F4 via the search help and selected an entry from the hit list which then were transported into that field.

I have got round it now, but if ther is no way of getting rid of the drop down marker on the field I can live with that.

Regards

Larissa

7 REPLIES 7

former_member188685
Active Contributor
0 Kudos

Hi,

what exactly your problem.., can you just tell me where you are facing the problem...

Regards

vijay

Message was edited by: Vijay Babu Dudla

Former Member
0 Kudos

As I have explained, I have fields that are editable AND are F4 enabled. What I want is for certain rows of the ALV that I do not want any procesing to occur to make all fields in that row not available for input AND not f4 enabled. I read a lock using a lock object. If the entry in my ALV matches the key locked in the lock object, I want that line to be in display mode only in the ALV with no F4 help being able to be called. It happens on the grid frontend when I press enter and have checked if any of my entries in my ALV are already locked by another user. The code is too long to post here. I can disbale the editable fields using MC_STYLE_DISABLED as described above but then the little drop down to enable F4 input is still visible against the field.

I have got round it by calling the f4 in event HANDLE_ON_F4 to not go via the search help and set er_event_data->m_event_handled = c_yes so that the F4 hit list does not appear, but I want to get rid of the drop down marker in that field in that instance.

Hope this is a little clearer now.

Larissa

0 Kudos

Hi,

even if you have F4 Help what makes the difference, since it is in disable mode. it will not do any thing .

if you see the transactions in display mode though F4 help is there you can't change it or do any thing..

Regards

vijay

Former Member
0 Kudos

Only when I did er_event_data->m_event_handled = c_yes without calling the search help did it work. What was happening was that although the field was disbaled, the contents of that cell where changing if I called F4 via the search help and selected an entry from the hit list which then were transported into that field.

I have got round it now, but if ther is no way of getting rid of the drop down marker on the field I can live with that.

Regards

Larissa

0 Kudos

Hi,

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.

Regards

vijay

Former Member
0 Kudos

Thaks Vijay. Had a look and it was changing in my data_changed method. However, will go with what I have done in that will not call search help in my HANDLE_ON_F4 method if lock field is set but make sure standard search help also does not appear.

Many thanks

Larissa

0 Kudos

Hi Larissa,

Can you help to share some updates on how you solved this ? We too have the same use case that when a new row is added, in that blank row for one of the column when F4 is pressed, the whole line is getting disabled and also F4 valuse is not getting selectable.