cancel
Showing results for 
Search instead for 
Did you mean: 

Strange Problem with Dropdown By Key - Displaying Keys instead of Texts

Former Member
0 Kudos

Hi Experts,

I have created a DropDownByKey UI Element on the Layout.

For some users, its working fine but for some users, its working strange. It looks like a language settings problem but we tried even that and no use.

The problem is the DropDownByKey is showing the list of Keys in the Browser instead of their associated Texts. To be more clearly, I created a DropDownByKey for a domain list that has following values

Key - Desc

-


0 - Materials

9 - Services

The UI Element on the screen shows that the dropdown has '0' and '9' instead of 'Materials' and 'Services'.

If you have come across such problem, can you please let us know how did you solve it?

Your earliest response will be highly appreciated.

Thanks,

Sri

Accepted Solutions (0)

Answers (5)

Answers (5)

kmoore007
Active Contributor
0 Kudos

I am having the same problem. When I click the drop-down, I see the texts. But when I select one, the key is displayed instead of the text.

Former Member
0 Kudos

Hi Kenneth

On selecting drop down u get the description,but after selection u get the key displayed right,

this means you set the attribute value to its key not its value.

On drop down u bind the attribute set with key value pair which in tun binds the attribute value to key, so on select method you have to bind the set-value to the attribute value.



lo_node->get_attribute(
    EXPORTING 
        name = <attribute_name>
    IMPORTING
         value = lv_attr_val ).

*lv_attr_val will have the key value.

READ TABLE lt_set INTO ls_set TRANSPORTING value.

lv_attr_val = ls_set-value.

lo_node->set_attribute(
    EXPORTING 
        name = <attribute_name>
         value = lv_attr_val ).

hope u get the text input field.

Regard

Nawal Kishor Mittal

Former Member
0 Kudos

Hi,

You need to maintain the translations from where the text is coming. e.g If some user is of DE language and u have not maintain the translation in that language then it show the keys in drop down.

Former Member
0 Kudos

hi,

This problem occurs mainly when you are using OTRs to populate values in dropdown and translations of Dropdown Values are not maintained.

Please maintain the translation for the languages in which you open the application.

Former Member
0 Kudos

hi Srinivas ,

Drop down by key will be used to map simple types created in dictionary . This simple type will have Key and the value. The value will be displayed in the drop down and by selecting it, we can get the corresponding key.

if u r using drop down by key , than proceed like this :

1 declare a context node of cardinality 0..1

2 declare attribute of type string under it . The attribute name should be exactly the same as that in database table '

eg if u want to poulate values for a field ' SYS' from table , than giv the attribute name as 'SYS' in context attribute

3 declare internal table of type standard table

4 populate internal table with values

5 take the refernce of the node , u have created

6 bind it with the internal table

here is one code as an example for ur reference , which shud display texts



TYPES: BEGIN OF str_roles,
  ->  role TYPE z0cz_roles-role_id,
 ->  END OF str_roles.
 
  ->DATA: it_role TYPE TABLE OF str_roles,
   ->    wa_role TYPE str_roles.
 
  ->DATA:          value1 TYPE wdy_key_value,
    ->       set TYPE wdy_key_value_table.
 
 
 -> SELECT role_id FROM z0cz_roles INTO TABLE it_role.
 
->SORT IT_ROLE DESCENDING BY ROLE.
->  LOOP AT it_role INTO wa_role.
 
  ->  value1-key = sy-tabix.
  ->  value1-value = wa_role-role.
  ->  APPEND value1 TO set.
   ->  ENDLOOP.
 
->  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('CN_DROPDOWN').
  ->node_info->set_attribute_value_set( name = 'CA_ROLE'   value_set = set ).

regards,

amit

Former Member
0 Kudos

SelectedKey is bound to which one.....what is your context attribute/node.....