07-18-2013 8:24 PM
I was wondering how one could automatically filter a column of an alv based on a parameter from the selection screen.
I have a program that generates a wide range of data and which I can then filter manually. In particular, I would like to stream line this process by adding the item I wish to to filter by as a selection option and then displaying the filtered results.
Thanks in advance for any advice.
-John
07-19-2013 4:37 AM
What is the problem?
List all the needed filter parameters in the selection screen as either 'select-option' or a 'Parameter'.
And then add to your select statement in the code, all there parameters in 'where' clause like
matnr = p_matnr in case your field is parameter
matnr in so_matnr in case your field is select-option.
If you are talking about a standard transaction, then filtering is the only solution, in case this field is not available in Selection-screen.
Jogeswara Rao K.
07-19-2013 4:37 AM
What is the problem?
List all the needed filter parameters in the selection screen as either 'select-option' or a 'Parameter'.
And then add to your select statement in the code, all there parameters in 'where' clause like
matnr = p_matnr in case your field is parameter
matnr in so_matnr in case your field is select-option.
If you are talking about a standard transaction, then filtering is the only solution, in case this field is not available in Selection-screen.
Jogeswara Rao K.
07-19-2013 4:38 AM
Hi John,
Just read the selection parameter values and then in the select statement which is used for displaying the result in ALV use the where clause to filter the values and store into an internal table.
Regards,
Satish D R
07-19-2013 4:47 AM
Hi John,
The ALV itself has the option of filter and you can pass the select option here directly if needed.
Fill the Select option value to the respective field and use it in the SET_FILTER_CRITERIA of the ALV Grid.
clear wa_filter.
refresh it_filter.
wa_filter-fieldname = 'MATNR'.
wa_filter-tabname = 'IT_FINAL'.
wa_filter-valuf = '000000000000000225'.
wa_filter-valut = '000000000000000250'.
wa_filter-valuf_int = '000000000000000225'.
wa_filter-valut_int = '000000000000000250'.
wa_filter-sign0 = 'E'.
wa_filter-optio = 'BT'.
append wa_filter to it_filter.
07-19-2013 6:00 AM
Hello John ,
if you want to filter your record from input provided by Select-option i think it can be solved by passing internal select-option low and select-option high with sign and option for Ranges as Mohammed said.
i don't known weather you use classical alv or oops alv .
1) for classical alv in REUSE_ALV_GRID_DISPLAY IT_FILTER TYPE SLIS_T_FILTER_ALV is a parameter you can fill that one and pass to function module and you can achieve your solution.
2)we have also option for oop alv Fm set_table_for_first_display
CALL METHOD r_alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'FS' " -------->( Pass structure name )
is_layout = w_lay " ----> (Pass layout structure )
CHANGING
it_outtab = itab "----> (Pass internal table which holds data )
it_fieldcatalog = t_cat "----->( Pass field catalogue)
it_sort = t_sort " -----> ( Pass Sort internal table)
it_filter = t_fil "----> ( Pass filter internal table ).
where filter table type as
w_fil TYPE lvc_s_filt,
t_fil TYPE lvc_t_filt.
for more detail
http://wiki.sdn.sap.com/wiki/display/ABAP/ALV+TUTOTIAL+FOR+BEGINERS+WITH+EXAMPLES
http://wiki.sdn.sap.com/wiki/display/ABAP/ALV+TUTOTIAL+FOR+BEGINERS+WITH+EXAMPLES
With Hope Your Problem will be Solved...