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