cancel
Showing results for 
Search instead for 
Did you mean: 

alv find the value entered by user in filter

Former Member
0 Kudos

Hi,

The normal filter of alv is enabled and user can key in any value against any column and hit enter.

I need to captured this value entered or atleast a reference to the filtered rows

Thanks,

Harish

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you can achive this by doing following:

1) go the view where you alv table is and click on method's tab

2) create an event handler method

2.1) click on the column which says method type and then change its type to event handler

2.2) on the same row go to column "component usage" and select your alv component

2.3)now on the same row go to columnn "event" and do f4 help on it and select "ON_STD_FUNCTION_AFTE"

3)now click on this newly created method and write the following code:


 DATA lo_r_param TYPE REF TO if_salv_wd_table_std_function	.

  lo_r_param = r_param.

  DATA lo_event TYPE REF TO cl_wd_custom_event.

  DATA value TYPE string.

  value = lo_r_param->id.

  IF value  = 'SALV_WD_FILTER_DEFINE'.

    DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

    l_ref_cmp_usage =   wd_this->wd_cpuse_alv_tab( ).
    IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
      l_ref_cmp_usage->create_component( ).
    ENDIF.

    DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
    l_ref_interfacecontroller =   wd_this->wd_cpifc_alv_tab( ).
    DATA:
          l_value TYPE REF TO cl_salv_wd_config_table.
    l_value = l_ref_interfacecontroller->get_model( ).

    DATA:
       ls_field_ref    TYPE salv_wd_s_field_ref,
       lt_field_ref    TYPE salv_wd_t_field_ref.
    DATA:
        ls_filter_rule  TYPE salv_wd_s_filter_rule_ref,
        lt_filter_rule TYPE salv_wd_t_filter_rule_ref.
    DATA:
       ls_selopt  TYPE cl_salv_bs_filter=>s_type_filter_selopt.


    lt_field_ref    = cl_salv_wd_model_table_util=>if_salv_wd_table_util_fields~get_filtered_fields(
    l_value ).

    LOOP AT lt_field_ref INTO ls_field_ref.
      lt_filter_rule = ls_field_ref-r_field->if_salv_wd_filter~get_filter_rules( ).

      CHECK LINES( lt_filter_rule ) GT 0.

      LOOP AT lt_filter_rule INTO ls_filter_rule.
        ls_selopt-low    = ls_filter_rule-r_filter_rule->get_low_value( ).
        ls_selopt-high   = ls_filter_rule-r_filter_rule->get_high_value( ).
        ls_selopt-option = ls_filter_rule-r_filter_rule->get_operator( ).
      ENDLOOP.
    ENDLOOP.
  ENDIF.

That is all...

your values will be in ls_selopt structure....i tested this in one of my Sand boxes and it works fine. you can put a break point here and see how it is working...

enjoy..

AS..

Answers (0)