cancel
Showing results for 
Search instead for 
Did you mean: 

ALV delete filter in WDA code

Former Member
0 Kudos

Guru's,

I have a WDA program with an ALV.

When I initialize the WDA for creating a new form I also want to delete the filter in the ALV (now this remains).

I have found the following code to create a button on the ALV to delete the filter but I want to do this also in coding (after INIT button) and not on the press of a button on the ALV.

Anyone know how to do this?


*--------------------------------------------------------------------------
* ALV 
*--------------------------------------------------------------------------
  DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

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

  DATA: r_table                   TYPE REF TO cl_salv_wd_config_table.
  DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .

  l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
  r_table = l_ref_interfacecontroller->get_model(  ).

  DATA: lr_functions TYPE REF TO if_salv_wd_function_settings.
  DATA: lr_function  TYPE REF TO cl_salv_wd_function.
  DATA: lr_button    TYPE REF TO cl_salv_wd_fe_button.

  lr_functions ?= r_table.

  lr_function = lr_functions->create_function( 'FILTER_DELETE' ).
  CREATE OBJECT lr_button.
  lr_button->set_text( 'Filter Delete' ).
  lr_function->set_editor( lr_button ).
  lr_function->set_function_std( if_salv_wd_c_std_functions=>filter_delete ).

Thanks,

Kris

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Any ideas?

Really need this !

Former Member
0 Kudos

Hi Hans,

There is a class named as CL_SALV_WD_FILTER and CL_SALV_WD_FILTER_RULE, check if any of the mentioned class method is useful. Not used them myself though.

One workaround could be to delete the component usage of ALV and instaniate it again. But this would be resource consuming practice.

Regards

Manas Dua

Former Member
0 Kudos

Hi Hans,

Check the following thread to first fetch all the filter rules applied to ALV.

Once you get the filter rules you can call methods delete_filter_rules or delete_filter_rule of interface IF_SALV_WD_FILTER.

Check the following link for more details

https://cw.sdn.sap.com/cw/docs/DOC-10827

Hope this helps

Regards

Manas Dua