Adding Filter Functionality in ALV Tree 1601295177
Adding Filter Functionality in ALV Tree 1601295177
😊
Hope this blog will help my fellow ABAPers who are developing out-of-the-box solutions every single day
. If you know other ways of adding this functionality, please do share!
CASE: Few months back, our client had a requirement to add filter criteria for Item Category in ALV Tree
in the custom report.
Challenge: Currently Standard SAP does not cater filter functionality in CL_ALV_TREE.
Solution: I was able to complete this requirement by adding a custom button on the ALV Toolbar and
using standard Function Module 'LVC_FILTER’ sharing the solution in attachment.
For Demo purposes, I have created a custom program from standard report BCALV_TREE_DEMO and
done custom changes to add filter functionality.
The below program shows the places at which I have incorporated the changes.
1. In the below program , under PBO in perform init_tree , I have added custom Filter button in
toolbar under subroutine perform change_toolbar.
Under the implementation part of the method on_filter_selected, adding the below code
*&---------------------------------------------------------------------*
*& Form FILTER_FUNCTION
*&---------------------------------------------------------------------*
* Filter Functionality for screen 100
*----------------------------------------------------------------------
FORM FILTER_FUNCTION .
DATA: lr_filters TYPE REF TO cl_salv_filters,
lr_filter TYPE REF TO cl_salv_filter,
lt_filters TYPE salv_t_filter_ref,
ls_filter TYPE salv_s_filter_ref,
DATA : l
t_col TYPE lvc_t_col,
ls_col TYPE lvc_s_col,
ls_layo TYPE lvc_s_layo,
lv_idx TYPE sy-tabix,
lx_hierarchy_header TYPE treev_hhdr,
ls_vari TYPE disvariant,
lt_filt_temp TYPE lvc_t_fidx.
ENDLOOP.
**We have to again free our container and the tree and recreate
PERFORM tree_recreate.
ENDFORM.
Output: