08-30-2017 12:48 PM
Hello everyone
I have a requirement to restrict the columns which the user can hide in an ALV-Grid. For example i have the column "Project" which needs to be filled and the column "Project description". The user should be allowed to hide the "Project description" column but shouldn't be able to hide the "Project" column. I have already looked for solutions on the web but sadly haven't found any. I also tried intercepting the user command with the "BEFORE_USER_COMMAND" event to edit the variant but it never applies the changes to the fieldcatalog. If you could provide me with any hints or even an answer I'd be very thankful.
Best Regards
Phil
08-30-2017 1:37 PM
You could handle the event AFTER_REFRESH of the ALV grid. Read the frontend field catalog. If and only some forbidden fields were hidden, update and set again the frontend field catalog and refresh the table display.
08-31-2017 7:25 AM
Hi Raymond
Sounds like an interesting approach but I think it'll be heavy on performance when i am constantly updating the frontend object. Nontheless thanks for your answer
Regards
Phil
08-31-2017 7:58 AM
I use this in some programs where subtotals are calculated from (strange) user rules and don't get performance problem. Of course I force a new display only when something (field catalog, total values, sort criteria) actually changed, so no refresh most of the time.
08-30-2017 1:50 PM
Hello,
Did you try to fill field KEY in fieldcat?
DATA t_fieldcatalog TYPE lvc_t_fcat.
FIELD-SYMBOLS <fieldcatalog> TYPE LINE OF lvc_t_fcat.
grid->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = t_fieldcatalog ).
LOOP AT t_fieldcatalog ASSIGNING <fieldcatalog>.
CASE <fieldcatalog>-fieldname.
WHEN 'FIX_COLNAME'.
<fieldcatalog>-key = 'X'.
clear <fieldcatalog>-no_out.
ENDCASE.
ENDLOOP.
grid->set_frontend_fieldcatalog( t_fieldcatalog ).
Best regards,
Bertrand
08-31-2017 7:24 AM
Hi Bertrand
Thanks for your answer. I haven't tried it yet, but in my expirience the field will get colored blue. I'll also try if using custom cellcolor will override this effect.
Regards
Phil
08-31-2017 7:30 AM
Hi Bertrand
I have just tried it sadly the columns can still be hidden. But thanks for your suggestion.
Regards
Phil
08-31-2017 7:31 AM
Hello everyone
I wanted to thank everyone for their answer but we have scrapped this approach and decided that all columns can be hidden and the user is responsible on what columns they'll hide.
Regards
Phil