Skip to Content
avatar image
Former Member

how to delete filter in alv table

Hi,

I am using an ALV table. after applying the filter , i moved to some other view.but when i comes back to the previous view ,the filter is still switched on.but i wanted to remove the filter line automatically when i navigate between screens. how to achieve this?

Regards,

Lakshmi.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 11, 2009 at 10:32 AM

    Hi Lakshmi

    get the field on which the filter is set. and then call the delete functionality

    data:
      lref_filter type ref to cl_salv_wd_field.
      lref_filter = wd_this->m_handler_alv->if_salv_wd_field_settings~get_field( 'MyField1' ).
    
      lref_filter->if_salv_wd_filter~set_filter_allowed( ).
      lref_filter->if_salv_wd_filter~delete_filter_rule( ).

    Greetings

    Prashant

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Lakshmi,

      Check this code regarding deletion of filter in alv table.

      method on_upload_complete .

      *... check ALV component usage

      data:

      lr_salv_wd_table_usage type ref to if_wd_component_usage.

      lr_salv_wd_table_usage = wd_this->wd_cpuse_salv_wd_table( ).

      if lr_salv_wd_table_usage->has_active_component( ) is initial.

      lr_salv_wd_table_usage->create_component( ).

      endif.

      *... get ALV component

      data:

      lr_salv_wd_table type ref to iwci_salv_wd_table.

      lr_salv_wd_table = wd_this->wd_cpifc_salv_wd_table( ).

      *... (1) get ConfigurationModel from ALV Component

      wd_this->r_table = lr_salv_wd_table->get_model( ).

      *... (2) configure ConfigurationModel

      *... init TableSettings

      data:

      lr_table_settings type ref to if_salv_wd_table_settings.

      lr_table_settings ?= wd_this->r_table .

      lr_table_settings->set_read_only( abap_false ).

      lr_table_settings->set_visible_row_count( '15' ).

      data:

      lr_header type ref to cl_salv_wd_header.

      lr_header = lr_table_settings->get_header( ).

      data:

      l_header type string.

      concatenate sy-sysid ' Flight overview' into l_header. "#EC NOTEXT

      lr_header->set_text( l_header ).

      lr_header->set_tooltip( 'Tooltip Flight Overview' ). "#EC NOTEXT

      lr_header->set_image_source( 'ICON_FLIGHT' ).

      lr_header->set_image_first( abap_false ).

      *... init FunctionSettings

      cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(

      r_model = wd_this->r_table ).

      cl_salv_wd_model_table_util=>if_salv_wd_table_util_funcs~set_functions_visible(

      r_model = wd_this->r_table

      value = cl_wd_uielement=>e_visible-none ).

      *... init ColumnSettings

      data:

      lr_column_settings type ref to if_salv_wd_column_settings.

      lr_column_settings ?= wd_this->r_table.

      data:

      lt_columns type salv_wd_t_column_ref.

      lt_columns = lr_column_settings->get_columns( ).

      data:

      ls_column type salv_wd_s_column_ref.

      loop at lt_columns into ls_column.

      case ls_column-id.

      when 'CARRID'.

      data:

      lr_uie_input_field type ref to cl_salv_wd_uie_input_field.

      create object lr_uie_input_field

      exporting

      value_fieldname = ls_column-id.

      ls_column-r_column->set_cell_editor( lr_uie_input_field ).

      when 'CONNID' or 'FLDATE' or 'PLANETYPE' or

      'PRICE' or 'CURRENCY' or 'SEATSOCC' or

      'DISTANCE' or 'DISTID'.

      when others.

      ls_column-r_column->set_visible( cl_wd_uielement=>e_visible-none ).

      endcase.

      endloop.

      *... init FieldSettings

      data:

      lr_field_settings type ref to if_salv_wd_field_settings.

      lr_field_settings ?= wd_this->r_table.

      data:

      lr_field type ref to cl_salv_wd_field.

      *... set reference fields

      lr_field = lr_field_settings->get_field( 'PRICE' ).

      lr_field->set_reference_field( 'CURRENCY' ).

      lr_field->set_reference_field_type( if_salv_wd_c_field_settings=>reffieldtype_curr ).

      lr_field = lr_field_settings->get_field( 'PAYMENTSUM' ).

      lr_field->set_reference_field( 'CURRENCY' ).

      lr_field->set_reference_field_type( if_salv_wd_c_field_settings=>reffieldtype_curr ).

      lr_field = lr_field_settings->get_field( 'DISTANCE' ).

      lr_field->set_reference_field( 'DISTID' ).

      lr_field->set_reference_field_type( if_salv_wd_c_field_settings=>reffieldtype_quan ).

      *... init Toolbar

      data:

      lr_functions type ref to if_salv_wd_function_settings.

      lr_functions ?= wd_this->r_table.

      data:

      lr_function type ref to cl_salv_wd_function.

      data:

      lr_button type ref to cl_salv_wd_fe_button.

      lr_function = lr_functions->create_function( 'FILTER' ).

      create object lr_button.

      lr_button->set_text( 'Filter' ). "#EC NOTEXT

      lr_function->set_editor( lr_button ).

      lr_function->set_function_std( if_salv_wd_c_std_functions=>filter ).

      lr_function = lr_functions->create_function( 'FILTER_DELETE' ).

      create object lr_button.

      lr_button->set_text( 'Filter Delete' ). "#EC NOTEXT

      lr_function->set_editor( lr_button ).

      lr_function->set_function_std( if_salv_wd_c_std_functions=>filter_delete ).

      lr_function = lr_functions->create_function( 'FILTER_DEFINE' ).

      create object lr_button.

      lr_button->set_text( 'Filter Define' ). "#EC NOTEXT

      lr_function->set_editor( lr_button ).

      lr_function->set_function_std( if_salv_wd_c_std_functions=>filter_define ).

      lr_function = lr_functions->create_function( 'UNDO' ).

      create object lr_button.

      lr_button->set_text( 'Undo' ). "#EC NOTEXT

      lr_function->set_editor( lr_button ).

      lr_function->set_function_std( if_salv_wd_c_std_functions=>edit_undo ).

      endmethod.

      Hope this will help you in solving ur problem

      Regard

      Manoj Kumar

  • avatar image
    Former Member
    Jun 17, 2010 at 04:14 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