Skip to Content
avatar image
Former Member

Restrict hideable columns in ALV-Grid

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Aug 30, 2017 at 12: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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 30, 2017 at 12: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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • avatar image
    Former Member
    Aug 31, 2017 at 06: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

    Add comment
    10|10000 characters needed characters exceeded