cancel
Showing results for 
Search instead for 
Did you mean: 

Capturing value of filter dropdown in ALV

Former Member
0 Kudos

I have an ALV table wherein I have enabled filtering, i.e., the in built automatic filter. Now there is a dropdown in the filterline. I want to capture the values in this filter dropdown (not the dropdown of the corresponding field !) as and when it changes. For this I have specified a predefined ALV event handler called 'ON_STD_FUNCTION_AFTE' which has importing parameters WDEVENT and R_PARAM. But both these attributes do not give me the value which is currently selected in the FILTER DROPDOWN.

How do I get this selected value from the filter dropdown ?

Edited by: Sukanya Mayuri Gogoi on Feb 24, 2009 3:58 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Prashant,

Thanks for your detailed reply. Unfortunately am not able to solve it still. Actually the solution you have proposed would create a filter dropdown function and then we can specify a key for this DD and capture it, right ? But I am referring to the in-built filter of the ALV table which automatically gets activated once the filter setting is switched on in the ALV.

This filterline in the ALV table gets activated for ALL the columns of the ALV, once switched on. And I want to capture the filter value of a specific column and also control its filtering manually, which I am still not able to.

Regards

Sukanya.

Former Member
0 Kudos

Hi Prashant,

Thanks for the input. Once I create this function called 'MY_FUNC' , how will I relate it to the filterline dropdown which is a built-in one.

For e.g., I had manually created a button on my ALV table and set my own function to it like this:

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

lr_function->set_visible( cl_wd_uielement=>e_visible-none ).

CREATE OBJECT lr_fe_button.

lr_fe_button->set_text( lv_button_text ).

lr_fe_button->set_tooltip( lv_tooltip ).

lr_fe_button->set_enabled( abap_true ).

lr_function->set_editor( lr_fe_button ).

But this filterline is automatic in the ALV table. How can a manually created function be linked to it ?

Best regards

Sukanya

Former Member
0 Kudos

Hi Sukanya,

below are detailed steps.

Step-1

while initializing the ALV i create this function as below

data:

lref_function type ref to cl_salv_wd_function,

lref_elementddi type ref to cl_salv_wd_fe_dropdown_by_idx,

lr_seperator1 type ref to cl_salv_wd_fe_separator.

create object lref_elementddi exporting texts_elementname = 'VALUE'.

lref_elementddi->set_label_text( value = 'ULN Values' ).

lref_function = wd_this->m_handler_alv->if_salv_wd_function_settings~create_function( 'ULN_FUNC' ).

Step -2

i declare event handler method( on_my_func_select ) in my view having this ALV for ON_FUNCTION event of ALV.

Step -3

within this event handler function to as i posted before

method on_my_func_select .
 
"i have context node with NAME my_func
"lref_function = wd_this->m_handler_alv->if_salv_wd_function_settings~create_function( 'My_func' ). 
 
  data:
    lv_my_func type string,
    value type string.
  data:
    node_my_func                       type ref to if_wd_context_node,
    elem_my_func                       type ref to if_wd_context_element,
    strumy_func                       type if_v_rep_das=>element_my_func ,
    item_key                            like stru_my_func-key.
 
  lv_my_func = r_param->id.
* Only interested in function related to ULN values
  if lv_my_func = 'My_func'.
* Call Mr. Wizard to read values of attribute KEY of ULN_FUNC
* navigate from <CONTEXT> to <my_func> via lead selection
    node_my_func = wd_context->get_child_node( name = if_v_rep_das=>wdctx_my_func ).
 
* get element via lead selection
    elem_my_func = node_my_func->get_element(  ).
 
* get single attribute
    elem_my_func->get_attribute(
      exporting
        name =  `KEY`
      importing
        value = item_key ).


endmethod.

Greetings

Prashant

Former Member
0 Kudos

HI Sukanya ,

'ON_STD_FUNCTION_AFTE' should use logic as stated below

method on_my_func_select .

"i have context node with NAME my_func
"lref_function = wd_this->m_handler_alv->if_salv_wd_function_settings~create_function( 'My_func' ). 

  data:
    lv_my_func type string,
    value type string.
  data:
    node_my_func                       type ref to if_wd_context_node,
    elem_my_func                       type ref to if_wd_context_element,
    strumy_func                       type if_v_rep_das=>element_my_func ,
    item_key                            like stru_my_func-key.

  lv_my_func = r_param->id.
* Only interested in function related to ULN values
  if lv_my_func = 'My_func'.
* Call Mr. Wizard to read values of attribute KEY of ULN_FUNC
* navigate from <CONTEXT> to <my_func> via lead selection
    node_my_func = wd_context->get_child_node( name = if_v_rep_das=>wdctx_my_func ).

* get element via lead selection
    elem_my_func = node_my_func->get_element(  ).

* get single attribute
    elem_my_func->get_attribute(
      exporting
        name =  `KEY`
      importing
        value = item_key ).

Item_key should be your selected key

Greetings

Prashant