Skip to Content
avatar image
Former Member

ALV delete filter in WDA code

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Mar 19, 2010 at 02:42 PM

    Any ideas?

    Really need this !

    Add comment
    10|10000 characters needed characters exceeded

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