Skip to Content
avatar image
Former Member

Delete filter

Hi,

I used the filter option to filter the values of a table. But when I run the next time the filter is still there. I am unable to delete this filter. So I tried the below code to delete the filter.

  • Delete Filters

data:

lref_filter type ref to cl_salv_wd_field.

lref_filter = lr_config_model->if_salv_wd_field_settings~get_field( 'CUSTOMER' ).

lref_filter->if_salv_wd_filter~set_filter_allowed( ABAP_TRUE ).

lref_filter->if_salv_wd_filter~delete_filter_rule( ).

But this code is also not working. Every time I run the application the filter is automatically applied and I need to manually delete this filter to see the results. And this is happening only for my user.

Appreciate your inputs on this.

Thanks,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 23, 2009 at 05:53 AM

    Hi,

    find the below code to delete filter rule.

    DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

    lo_cmp_usage = wd_this->wd_cpuse_alv_use( ).

    IF lo_cmp_usage->has_active_component( ) IS INITIAL.

    lo_cmp_usage->create_component( ).

    ENDIF.

    DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

    lo_interfacecontroller = wd_this->wd_cpifc_alv_use( ).

    DATA lo_value TYPE REF TO cl_salv_wd_config_table.

    lo_value = lo_interfacecontroller->get_model(

    ).

    DATA lr_field_settings TYPE REF TO if_salv_wd_field_settings.

    DATA lr_field TYPE REF TO cl_salv_wd_field.

    lr_field_settings ?= lo_value.

    clear lr_field.

    lr_field = lr_field_settings->get_field( 'ZZAGREEMENT_ID' ). " your column name

    lr_field->if_salv_wd_filter~delete_filter_rule( ).

    clear lr_field.

    lr_field = lr_field_settings->get_field( 'ZZ_STATUS' ). " your column name

    lr_field->if_salv_wd_filter~delete_filter_rule( ).

    Like this you can delete filter rules for the table coulmns.

    Regards,

    Lakshmi.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Lakshmi. But the code you pasted is similar to the code I pasted in my question. It some how doesn't seems to work. Any clues?

      Thanks,

  • avatar image
    Former Member
    Jul 08, 2009 at 10:56 PM

    Not answered but closign because of the restriction of 10 questions

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 17, 2010 at 04:16 PM

    Hi, i had the same problem. You can delete all filter with this code:

    "Create some code using the code wizard ( call instance of used alv)

    DATA:

    l_value TYPE REF TO cl_salv_wd_config_table,

    lo_interface TYPE REF TO iwci_salv_wd_table.

    TRY.

    lo_interface = wd_this->wd_cpifc_alv_serv( ).

    CATCH cx_wdr_rt_exception.

    ENDTRY.

    l_value = lo_interface->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.

    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( ).

    ls_field_ref-r_field->if_salv_wd_filter~delete_filter_rules( ).

    ENDLOOP.

    Regards

    Josip

    Add comment
    10|10000 characters needed characters exceeded