Skip to Content
Author's profile photo Chris Bailey

Full screen CL_SALV_TABLE – Excluding PF-Status functions (a solution)

I’m sure we all know by now that CL_SALV_TABLE is an excellent class for quickly presenting tabular data to the user.  However, it’s not without its limitations and annoyances (as I’m sure you all know by now as well).

One of the (admittedly minor) things that irritates me about working with CL_SALV_TABLE is the inability to exclude GUI functions when using the full screen variant of the ALV.  This has finally prompted me to do something about it!

So, the way we normally set a custom PF-Status when using the full-screen variant of the ALV is to use the SET_SCREEN_STATUS method of CL_SALV_TABLE.

Easy enough…

o_salv_table->set_screen_status( report = 'ZMYREPORT'
                                 pfstatus = 'CUSTOM_FULLSCREEN' ).

However, this method provides no way of specifying functions to exclude should we need to.

For those who may have tried, using CL_SALV_TABLE->GET_FUNCTIONS and attempting to use ENABLE_FUNCTION to disable functions is fruitless and ultimately ends in a short-dump telling you this action isn’t supported for full-screen SALV variants.

Wouldn’t it be nice if we could just write something like:

o_salv_table->set_screen_status( report = 'ZMYREPORT'
                                 pfstatus = 'CUSTOM_FULLSCREEN'
                                 excluding = gt_extab ).

Well, with a couple of implicit enhancements (3 to be precise) you now can!

Enhancement 1

In class CL_SALV_MODEL_BASE display the “Attributes” tab and click on the “Enhance” icon.  Create an Enhancement Implementation and corresponding Composite Enhancement Implementation.  e.g.

Create a new attribute called something like “I_FULLSCREEN_EXCLUDE_PF” (I’m sure you’ll think of something better) with a type of KKBLO_T_EXTAB.  This attribute should be an Instance Attribute and have Public scope/visibility.

Within the same class (CL_SALV_MODEL_BASE) select the Methods tab and view the parameters for method SET_SCREEN_STATUS.

Add a new importing parameter called “Excluding” also with a type of KKBLO_T_EXTAB.

Save and activate the enhancement.

Enhancement 2

Within the same class (CL_SALV_MODEL_BASE), view the source code for the aforementioned method SET_SCREEN_STATUS.  Click on the “Enhance” icon again and use the menu option to Show Implicit Enhancement Options.  Scroll to the bottom of the method code and create a new Code enhancement at the bottom, right before the “ENDMETHOD” statement.  Make sure it’s a component of the Composite Enhancement Implementation that you created in the first step.

Use the following code in this enhancement:

if excluding is supplied.
  me->i_fullscreen_exclude_pf[] = excluding[].
endif.

Save and activate the enhancement.

Enhancement 3

The final enhancement takes place in class CL_SALV_FULLSCREEN_ADAPTER, so this new functionality will only take effect for the full-screen variant of CL_SALV_TABLE.

View the code for method IF_SALV_STATUS_ADAPTER~BUILD_UIFUNCTION and you will see it does some stuff with a T_EXTAB internal table.  This is the table we need to modify if any exclusions have been passed to SET_SCREEN_STATUS.

So, as in the previous step, we need to create another Implicit Enhancement at the end of the method code, again making sure it’s part of the same Composite Enhancement Implementation.

Then copy the following code into the enhancement:

if lr_model is bound and lr_model->i_fullscreen_exclude_pf[] is not initial.
  append lines of lr_model->i_fullscreen_exclude_pf to t_extab.
endif.

Save and activate the enhancement and we’re done!  Enjoy!

Let me know what you think and if you can think of any improvements.  Admittedly, the additional attribute on CL_SALV_MODEL_BASE feels a bit hacky.

Assigned Tags

      12 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Shai Sinai
      Shai Sinai

      You may use method REMOVE_FUNCTION (and not ENABLE_FUNCTION).
      It should do the work.

      Author's profile photo Chris Bailey
      Chris Bailey
      Blog Post Author

      Hi Shai,

      I did try this, but unfortunately like ENABLE_FUNCTION it does not work for full-screen SALV variants.  This is due to this branch within the method…

        if lr_controller->r_model->get_display_object( )
                                eq if_salv_c_table_objects=>grid.
          value = remove_item( name ).
        else.
          l_name = name.
          message w027(salv_exception)
            with 'CL_SALV_FUNCTIONS' 'REMOVE_FUNCTION' 'Function: ' l_name
            into l_msgtext.                                       "#EC NOTEXT
      
          ls_message-msgid = sy-msgid.
          ls_message-msgno = sy-msgno.
          raise exception type cx_salv_wrong_call
            exporting
              textid   = ls_message
              object   = 'Function'
              key      = l_name
              class    = 'CL_SALV_FUNCTIONS'                      "#EC NOTEXT
              method   = 'REMOVE_FUNCTION'.                       "#EC NOTEXT
        endif.

      Kind regards,

      Chris.

      Author's profile photo Shai Sinai
      Shai Sinai

      You're right.
      In case of fullscreen, you should use method SET_FUNCTION.

      P.S.
      I do agree that all these combinations (for grid/fullscreen mode) are quite confusing.
      You may check demo program SALV_TEST_FUNCTIONS as reference.

      Author's profile photo Jesús Antonio Santos Giraldo
      Jesús Antonio Santos Giraldo

      Nice document !

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Yes, "enable" in the method name seems like a clear indication that it's not for disabling something. Scratching my head here...

      There is also an old answered question on SCN on this. Found it by using "SALV disable function" in Google.

      Author's profile photo Chris Bailey
      Chris Bailey
      Blog Post Author

      Thanks for the info Jelena.  You know, I could have sworn I tried this (maybe it was SET_ENABLE I tried instead??)... just tried it again and yes, that does appear to work!  Oh well, I do like the convenience of the extended SET_SCREEN_STATUS method.  🙂

      Author's profile photo Andreas Bohlender
      Andreas Bohlender

      It's working! Many thanks for that!

      Author's profile photo Sandra Rossi
      Sandra Rossi

      Maybe you implemented the enhancements (?), but you may also see in the comments that there are 2 standard solutions:

      1. Simple one:
        DATA(functions_list) = o_salv_table->get_functions( ).
        functions_list->set_function( name = 'MYFUNCT1' boolean = abap_false ).
      2. More complex:
          DATA(lt_func_list) = o_salv_table->get_functions( )->get_functions( ).
          LOOP AT lt_func_list INTO DATA(la_func_list).
            IF la_func_list-r_function->get_name( ) = 'MYFUNCT1'.
              la_func_list-r_function->set_visible( ' ' ).
            ENDIF.
          ENDLOOP.
      Author's profile photo Thomas Werner
      Thomas Werner

      Great to solve that within the standard! I had the issue that the custom button was not in the list.

      Solution: Copy pf status and use the copied one.
      (Found here: https://answers.sap.com/comments/11803066/view.html)

      Author's profile photo Marian Stefanak
      Marian Stefanak

      HELLO,

      I would like to ask, is there any similar way, how to do that on CL_SALV_HIERSEQ_TABLE ???

      thanks for reply.

      Author's profile photo Sandra Rossi
      Sandra Rossi

      The output of class CL_SALV_HIERSEQ_TABLE is an ABAP List which uses the SAP GUI “Application Toolbar” which has standard buttons that cannot be extended (while this post is about the ALV grid control which has its own dynamic “Toolbar Control”), so the only solution is to “Copy pf status and use the copied one” cf comment above of Thomas Werner.

      Author's profile photo John Moulding
      John Moulding

      This is really useful:  I needed precisely this functionality,  I searched, found it,  and it took 10 minutes to implement.

      It works like a dream.

      Thanks Chris,  nice job!

      John M.