cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the selected entry from a Dropdown (using IF_WD_SELECT_OPTIONS)

Former Member
0 Kudos

Hello,

I created a Selection screen by adding attribute M_HANDLER of type IF_WD_SELECT_OPTIONS.

This way I can create a selection screen with normal select-options.

Now I added a parameter for a dropdown list. The Value set is passed correctly. No problem there. The values are filled and diplayed correctly.

* add the SHIP-TO field to the selection
  DATA: ltp_text  TYPE string.
  DATA: lta_ship_to_table type WDY_KEY_VALUE_table,
        lwa_ship_to       like LINE OF lta_ship_to_table.
  DATA: context_node_ship_to_table TYPE REF TO if_wd_context_node.

* get all declared attributes
  context_node_ship_to_table = wd_context->get_child_node( 'SHIP_TO_TABLE' ).
  context_node_ship_to_table->get_static_attributes_table(
    IMPORTING
      table  = lta_ship_to_table ).

  ltp_text = wd_assist->if_wd_component_assistance~get_text( 'L01' ).
  wd_this->m_handler_dlv->add_parameter_field(
                         i_id           = 'KUNWE'
                         i_description  = ltp_text
                         i_as_dropdown  = 'X'
                         it_value_set   = lta_ship_to_table
                         i_within_block = 'BLK1' ).

The problem is to GET the selected value in the method that is called after clicking on the Search button.

I tried using several methods, for example GET_PARAMETER_FIELD and GET_SELECTION_SCREEN_ITEMS.

* Get the Ship-to
  DATA: ltp_kunwe       TYPE REF TO data.
  ltp_kunwe = wd_this->m_handler_dlv->get_value_of_parameter_field(
                                        i_id = 'KUNWE' ).
* Assign it to a field symbol
  ASSIGN ltp_kunwe->* TO <fs_kunwe>.

Result was INITIAL.

DATA: lrf_get_selection_screen_items TYPE if_wd_select_options=>tt_selection_screen_item.
  wd_this->m_handler_dlv->get_selection_screen_items(
              IMPORTING
                 et_selection_screen_items = lrf_get_selection_screen_items ).

Result was INITIAL, although the table was retrieved with all values.

wd_this->m_handler_dlv->get_parameter_field(
                                      EXPORTING
                                        i_id = 'KUNWE'
                                      IMPORTING
                                        e_value = ltp_kunwe ).

Also INITIAL.

It looks like I am missing a step (maybe to set lead selection for this field). What did I miss?

How can I get to the value?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The strange thing is that the type WDY_KEY_VALUE consists of two fields, both of type string.

But when debugging, the length seems to be 1.

Example values in drodown list:

1 A1

2 A2

3 B1

4 A3

If those are the values, then selecting A1 or A2 returns the value 1.

If I select B1 or A3, then the value will be 2.

If the first character changes, then the next index starts, until the character changes again.

It MUST be something really stupid that I am doing wrong...

Former Member
0 Kudos

Hi Edwin.

please look at example wdr_test_select_options

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks!

Problem solved:


DATA: lr_value             TYPE REF TO data.

CREATE DATA lr_value TYPE string.                     "<----  I was missing this code

  LOOP AT lta_ship_to_table INTO lwa_ship_to.
    value_set-key   = lwa_ship_to-key.
    value_set-value = lwa_ship_to-value.
*    INSERT value_set INTO TABLE lt_value_set.
    append value_set TO lt_value_set.
  ENDLOOP.

  ltp_text = wd_assist->if_wd_component_assistance~get_text( 'L01' ).
  wd_this->m_handler_dlv->add_parameter_field(
                          i_description  = ltp_text
                          i_id           = 'KUNWE'
                          i_value        = lr_value   "<----  I was missing this code
                          i_as_dropdown  = abap_true
                          it_value_set   = lt_value_set
                          i_within_block = 'BLK1' ).

I looked at that parameter, but thought is was only used to SET the value, not required to get it back as well. Because it IS an import parameter...

Former Member
0 Kudos

Hi Edwin

data: lrf_get_selection_screen_items type if_wd_select_options=>tt_selection_screen_item.

use wd_this->m_handler_dlv->get_selection_screen_items(

IMPORTING

et_selection_screen_items = lrf_get_selection_screen_items ).

lrf_get_selection_screen_items-M_VALUE wil have the selected key.

Make sure the key you are using is correct. even the key is a string field use only integer values

Flip

Edited by: F. van Leeuwen on Sep 11, 2009 1:19 PM

Edited by: F. van Leeuwen on Sep 11, 2009 1:20 PM