Skip to Content
0

Restrict hideable columns in ALV-Grid

Aug 30, 2017 at 11:48 AM

63

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Bertrand DELVALLEE Aug 30, 2017 at 12:50 PM
1

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
Former Member

Hi Bertrand

I have just tried it sadly the columns can still be hidden. But thanks for your suggestion.

Regards
Phil

0
Raymond Giuseppi
Aug 30, 2017 at 12:37 PM
0

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0

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.

0
avatar image
Former Member Aug 31, 2017 at 06:31 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded