cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Dropdown by key..!

Former Member
0 Kudos

Hi All,

I am using drop down by key in my view. it contains years (like 2008,2009....) .

I want to display data in a table based on the selection of dropdownbox. .

But if i am selecting 1st or 2nd or 3rd i am getting this error...

'The value selectedKey = "2" in DropDownByKey "DROP1" does not exist in the value list and is not initial either �ꯂᢾ��P"

I don't know why i am getting this error.....!

my drop down code is....


data: value type WDR_CONTEXT_ATTR_VALUE,
        value_set type WDR_CONTEXT_ATTR_VALUE_LIST.
 
      data node_info type ref to if_wd_context_node_info.
 
      node_info = wd_context->get_node_info( ).
      
     node_info = node_info->get_child_node( wd_this->wdctx_yrnode ).
      value-value = 1.
     value-text = 2008.
      insert value into table value_set.
 
    value-value = 2.
    value-text = 2009.
    insert value into table value_set.
 
    value-value = 3.
    value-text = 2010.
    insert value into table value_set.
    
    value-value = 4.
    value-text = 2011.
    insert value into table value_set.
     
    node_info->set_attribute_value_set( name = 'YEAR' 
                                        value_set = value_set ).

I have given node properties like this

cardinality : 0..n

selection: 0..1

set lead selection : yes

Can anyone provide me solution to overcome this error.

Thans in Advance...!

Edited by: sreelakshmi.B on Jul 21, 2009 12:50 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks!

Former Member
0 Kudos

Hi,

Are you setting the default value for this dropdown anywhere ?

If so make sure that you set your value and not text.

Radhika.

Former Member
0 Kudos

Hi Sreelakshmi,

There is no problem in your coding for populatingdrop down values.Can you post your code here of onaction of drop down .

Former Member
0 Kudos

Code this way,

DATA lo_nd_nd_<nodename> TYPE REF TO if_wd_context_node.

DATA lo_nd_nd_info TYPE REF TO if_wd_context_node_info.

  • navigate from <CONTEXT> to <ND_nodename> via lead selection

lo_nd_nd_<node_name> = wd_context->get_child_node( name =

wd_this->wdctx_nd_<nodename> ).

  • get element via lead selection

lo_nd_nd_info = lo_nd_nd_<nodename>->get_node_info( ).

append ur values to table of type wdr_context_attr_value_list.

  • set all declared attributes

lo_nd_nd_info->set_attribute_value_set(

EXPORTING

name = 'YEAR'

value_set = <tablename> ).

Hope this mite work.Before getting the node information,you have to instantiate the

node object.

Regards,

Divya.S

Former Member
0 Kudos

Hi Suman,

This is my onAction() code...


data lo_nd_yts_mstr_holiday type ref to if_wd_context_node.
data lo_el_yts_mstr_holiday type ref to if_wd_context_element.
data lt_yts_mstr_holiday type wd_this->elements_yts_mstr_holiday.


lo_nd_yts_mstr_holiday = wd_context->get_child_node( name =
wd_this->wdctx_yts_mstr_holiday ).

***** reading attribute of dropdown select *******
  DATA:
    node_yrnode     TYPE REF TO if_wd_context_node,
    elem_yrnode     TYPE REF TO if_wd_context_element,
    stru_yrnode     TYPE if_emp_holiday=>element_yrnode ,
    item_year       LIKE stru_yrnode-year.

* navigate from <CONTEXT> to <YRNODE> via lead selection
  node_yrnode = wd_context->get_child_node( name = 
if_emp_holiday=>wdctx_yrnode ).

* @TODO handle not set lead selection
  IF ( node_yrnode IS INITIAL ).
  ENDIF.

* get element via lead selection
  elem_yrnode = node_yrnode->get_element(  ).

* @TODO handle not set lead selection
  IF ( elem_yrnode IS INITIAL ).
  ENDIF.

* get single attribute
  elem_yrnode->get_attribute(
    EXPORTING
      name =  `YEAR`
    IMPORTING
      value = item_year ).

********* selection criteria ***********

data lt_dats          type TABLE OF dats.
data l_dat_i          type          i.
data l_dat_c_4(4)     type          c.
data l_dat_c_12(12)   type          c.
data l_dats_from      type          dats.
data l_dats_to        type          dats.

*move date from integer to char
l_dat_c_4 = l_dat_i = item_year.

*create date-from use in WHERE clause.
CONCATENATE '01.01.' l_dat_c_4 INTO l_dat_c_12.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
   EXPORTING
     date_external  = l_dat_c_12
   IMPORTING
     date_internal  = l_dats_from
   EXCEPTIONS
     date_external_is_invalid = 1
     OTHERS                   = 2.

*create date to use in WHERE-clause.
CONCATENATE '31.12.' l_dat_c_4 INTO l_dat_c_12.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
  date_external  = l_dat_c_12
IMPORTING
  date_internal  = l_dats_to
EXCEPTIONS
  date_external_is_invalid = 1
  OTHERS                   = 2.


select * from yts_mstr_holiday into CORRESPONDING FIELDS OF TABLE
   lt_yts_mstr_holiday WHERE hdate BETWEEN l_dats_from
                                                          AND     l_dats_to.

lo_nd_yts_mstr_holiday->bind_table( lt_yts_mstr_holiday ).

Edited by: sreelakshmi.B on Jul 21, 2009 1:37 PM

Former Member
0 Kudos

Hi Sreelakshmi,

You are doing one simple mistake i.e you are always reading lead selection element not the selected element value.

* get element via lead selection
  elem_yrnode = node_yrnode->get_element(  ).

The above one always give first element or lead selection of node not the selected element.That's why when you select the first element it is not giving.But it is giving dump when you select 2nd or 3 rd record.

Now check the code below to get selected element.

CALL METHOD wdevent->get_context_element

EXPORTING

name = 'CONTEXT_ELEMENT'

receiving

value = elem_yrnode .

  • get single attribute

elem_yrnode->get_attribute(

EXPORTING

name = `YEAR`

IMPORTING

value = item_year ).

Now you will not get the dump.Write as it is.

Former Member
0 Kudos

Hi,

Please check the below things.

1. If you are not using table and drop down in a table, then change the CARDINALITY of the node YRNODE to 0:1, and keep the ONACTION CODE as it is. Other wise, change the ONACTION code as said by SUMAN above.

2. I think into the variable 'ITEM_YEAR', what you get is VALUE not TEXT. That is in your case, 1 or 2 or 3.. but not years. Change the code accordingly.

It should work after these changes.

Regards,

Manne.

Former Member
0 Kudos

Hi Rajashekar,

Thanks for your replay.

How to get ''text" instead of "value" into "item_year" variable?

(i.e years 2008,2009, 2010...)

Former Member
0 Kudos

Hi,

While filling the valuset table....fill the internal table with the key and text value parallely.

Then when key is retrieved from get_attribute,use read statement to get the value as,

read table table_name into structure with key key = value got from get_attribute.

now ur structure will have the correspomding key and value.

Thanks,

Divya.S

Former Member
0 Kudos

Hi,

I would say, easy way is to set VALUE & TEXT both as years(that is 2007, 2008,...), then you will get year into that variable and doesn't need any change in your codeline too.

Regards,

Manne.

Former Member
0 Kudos

Hi Divya,

Can you please explain me in detail......How to get the text of dropdown?

By reading the context attribute from codewizard, i got this code, But it was taking value.


DATA:
  node_yrnode                         TYPE REF TO if_wd_context_node,
  elem_yrnode                         TYPE REF TO if_wd_context_element,
  stru_yrnode                         TYPE if_emp_holiday=>element_yrnode ,
  item_year                           LIKE stru_yrnode-year.

* navigate from <CONTEXT> to <YRNODE> via lead selection
  node_yrnode = wd_context->get_child_node( name = if_emp_holiday=>wdctx_yrnode ).

* get element via lead selection
  elem_yrnode = node_yrnode->get_element(  ).

* get single attribute
  elem_yrnode->get_attribute(
    EXPORTING
      name =  `YEAR`
    IMPORTING
      value = item_year ).

Thanks in advance.!

Former Member
0 Kudos

Hi,

As i said, you can set both TEXT & VALUE as same while setting the value set for attribute.

OR

Before setting the value set, store the same data in some other internal table(example declare a table of same type in ATTRIBUTES tab of your view). Then use the below code before calling method node_info->set_attribute_value_set.

WD_THIS->VALUE_SET = value_set.

Now, access this table, read with selected value and find the corresponding value year as below.

data: value type WDR_CONTEXT_ATTR_VALUE.
Read table wd_this->value_set into value with key VALUE = ITEM_YEAR.
  " where ITEM_YEAR is the value selected in dropdown.

Regards,

Manne.

Former Member
0 Kudos

Hi,

In ur drop down code,

value-value = 1.

value-text = 2008.

insert value into table value_set.

value-value = 2.

value-text = 2009.

insert value into table value_set.

value-value = 3.

value-text = 2010.

insert value into table value_set.

value-value = 4.

value-text = 2011.

insert value into table value_set.

create a intenal table with fields key and value.

And fill this internal table when u fill the table value_set as

value-value = 1.

value-text = 2008.

ls_structure-key = 1.

ls_structure-value = 2008.

append ls_struture to lt_table.

insert value into table value_set.

now..using get_aatribute,u ll get the key ,that is ,1

In order to get the corresponding value 2008 for the key,use

read table lt_table into ls_structure with key key = 1.

Now ur ls_structure-value will have 2008 for the key 1.

Otherwise,as said by Manne,assign value ans text as 2008 itself.So that

when u use get_attribute,u ll get 2008 itself.

value-value = 2008.

value-text = 2008.

Hope this helps u!!!

Thanks,

Divya.S