cancel
Showing results for 
Search instead for 
Did you mean: 

Need DropDowns showing texts, not the key

Former Member
0 Kudos

Hi Experts,

I have the following scenario:

Table OrgUnit:

ID...OrgUnitName

-


01...Sales

02...Marketing

03...Operations

-


Table User

ID...Name.....OrgUnit

-


01...Schmitt...02

02...Meier......03

03...Heinz......02

-


Now, I want to provide a WebDynpro form for User Maintenance where the OrgUnit should be selected via DropDown. The DropDown should offer both OrgUnit ID and Name. After an entry is clicked, the DropDown should contain also both: ID and name of the OrgUnit. I managed it to fill the DropDown as described, but after selecting one entry the DropDown box only contains the key (I speak about the collapsed DropDown!).

Is there a simple way to get this working and to display the text and the key (the key is the value which will be saved)?

Regards, Steffen

Edited by: Steffen Weber on Jan 20, 2009 11:31 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

How are you populating the drop down? Are you setting the value set manually?

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

Thanks for your answer.

And yes, I populate the values via a value set which I bind to the corr. context attribute.

To be honest, the DropDown is embedded in an ALV, but I assume this has the same behavior as the a "normal" DropDown UI on a form.

I would appreciate it if there's another way how to get the values into the DropDown and have the result I expect!

Kind regards, Steffen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You haven't supplied any details about your coding, so it is difficult to say where the problem might be. I can tell you that I looked at an application I have and it is displaying the value and not the key after the DDLB is selected in the table display. So it would seem not to follow what you are seeing in your application.

I'm just setting the DDLB value set like always and not doing anything special to the UI element.

Here is the code I am using to fill the value set

DATA l_activities TYPE zpm_activity_typ_tbl.
  l_activities = wd_assist->read_all_activities( ).
  DATA lt_valueset TYPE wdr_context_attr_value_list.
  FIELD-SYMBOLS <wa_act> LIKE LINE OF l_activities.
  FIELD-SYMBOLS <wa_vs>  LIKE LINE OF lt_valueset.

  LOOP AT l_activities ASSIGNING <wa_act>.
    APPEND INITIAL LINE TO lt_valueset ASSIGNING <wa_vs>.
    <wa_vs>-value = <wa_act>-activity_type.
    CONCATENATE <wa_act>-activity_type ` - ` <wa_act>-activity_desc into <wa_vs>-text.
  ENDLOOP.



  DATA lo_nd_meeting TYPE REF TO if_wd_context_node.
* navigate from <CONTEXT> to <MEETING> via lead selection
  lo_nd_meeting = wd_context->get_child_node( name = wd_this->wdctx_meeting ).
  DATA lo_node_info TYPE REF TO if_wd_context_node_info.
  lo_node_info = lo_nd_meeting->get_node_info( ).
  lo_node_info->set_attribute_value_set(
     name = 'ACTIVITY_TYPE'
     value_set = lt_valueset ).

Edited by: Thomas Jung on Jan 20, 2009 10:14 AM

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

yes, this is exactly the way I do it!

And my DropDown offers the ORGUNIT-Names when open, but after clicking an entry the collapsed DropDown displays the ORGUNIT-ID.

Ok, the ID should be saved later on, but I would be nice to see the text, and not the value of the value-set item.

Any change?

Regards, Steffen


  lr_node = wd_context->get_child_node( name = 'USER' ).
  lr_node_info = lr_node->get_node_info( ).

* Prepare Value Set
  LOOP AT lt_org INTO lv_org.
      wa_value_set-value = lv_org-id.
      wa_value_set-text  = lv_org-name.
      INSERT wa_value_set INTO TABLE lt_value_set.
  ENDLOOP.

* Set attribute info by binding value set
  lr_node_info->set_attribute_value_set( name      = 'ORGUNIT'
                                           value_set = lt_value_set ).

* Change Cell Editor of Column to DropDown
  lr_column = lr_config->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN('ORGUNIT').
  CREATE OBJECT lr_dropdown_key
       EXPORTING
          selected_key_fieldname = 'ORGUNIT'. 

  lr_column->set_cell_editor( lr_dropdown_key ).

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I just tested this in a table vs. an ALV. It works perfectly fine in a table, but not in the ALV. I get the same results. I can only guess that this has to do with the way that the ALV makes an internal copy of the context or that it simply renders things differently.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

and you think that there is currently no solution for this issue?

Regards, Steffen