cancel
Showing results for 
Search instead for 
Did you mean: 

DropDown - With text explanation on the dropdown

Former Member
0 Kudos

Hi,

I would like to get a drop down with explanation on the dropdown but on selection only key must be selected.

for eg . Here are the dropdown values

US  United States

AU  Australia

NZ  Newzeland

DE  Germany

when selected the dropdown field should contain only US or AU. Is there a way to achieve this.

Thanks

Accepted Solutions (0)

Answers (7)

Answers (7)

amy_king
Active Contributor
0 Kudos

Hi Chinna,

If you happen to have release 7.0 enhancement pack 3, the DropDownByKey element has a keyVisible property that will let you achieve this automatically. If you're on a lower enhancement pack, you can build the dropdown's value set yourself with method set_attribute_value_set and control what values are used for the key and display text. So you could simply concatenate the country code and its text description and use that for the display value while leaving the key as just the country code.

  ls_option-value = 'US'.
  ls_option-text = 'US United States'.

Cheers,

Amy

chengalarayulu
Active Contributor
0 Kudos

Interesting discussion..

Chinna,

for displaying purpose only we can't do this... let user select the item, later on your action wherever you compare with code,,, there and all we can read only code..

NODE

     CODE

     DESC - bound to DropDown

after reading selected item of dropdown, we can consider only CODE.

Former Member
0 Kudos

HI,

I think when we select one element from dropdownlist and in wdmodifyview method we can read that list element value in temporary variable (var). We can process this variable to get  the country code easily by using split command.

data : var1 type string ,

           var2  type string.

SPLIT var AT SPACE INTO var1 var2.

OR

SPLIT var AT ' ' INTO var1 var2.

Here var1  will be the selected country code.

Thanks

Santosh.

former_member230486
Contributor
0 Kudos

Hi,

Initially you have to take a node with two attributes Key and Value.In the node you have to use supply function method to assign default values what ever you want.(by default it gives code,you just append the values to the internal table and bind it to internal table).

In the supply function method you have to write code additionally which is shown below,

ls_ddbi-key   = 'United States'.

ls_ddbi-value = 'US'.

APPEND LS_DDBI TO LT_DDBI.

ls_ddbi-key   = 'Australia'.

ls_ddbi-value = 'AU'.

APPEND LS_DDBI TO LT_DDBI.

Similarly append the remaining values.

Former Member
0 Kudos

Hi chinna,

As per my understanding  u r passing the data combinely....Means u r concatenating both country code and description..  and passing to key value......In this case it will come like this only....

Then u have to create 2 attribute.

key and value.

in key u have to send country code  and in value  u have to pass description  and add to internal table...

and bind the key to dropdown element...

Then at output u can get only country value......

Regards,

Venkat

Archie-Hammer
Explorer
0 Kudos

this all, of course depends on your context and which drop down element you choose to use.

If you bind your context as such.

DATA: lo_nd TYPE REF TO if_wd_context_node,
         lo_nd_info TYPE REF TO if_wd_context_node_info.

data: it_value_list TYPE wdr_context_attr_value_list,

          is_value like line of it_value_list.

data: iv_key type any,

iv_text type string.

lo_nd = wd_context->get_child_node( name = wd_this->wdctx_whatever ).

lo_nd_info = lo_nd->get_node_info( ).

select code text from somewhere into (iv_key, iv_text).

is_value-value = iv_key.

is_value-text = iv_text.

append is_value to it_value_list.

endselect.

lo_nd_info->set_attribute_value_set( name = 'COUNTRY' value_set = it_value_list ).

On your view use the DropdownByKey and bind the selected key property to the country attribute and check the KeyVisible field. Otherwise you can set it dynamically in the modifyview method and set the flag with CL_WD_DROPDOWN_BY_KEY->SET_KEY_VISIBLE.

hope this helps.

former_member220853
Participant
0 Kudos

Are you saying that values shall be shown as

US United states

and the key shall be only US ?

Former Member
0 Kudos

Yes show as US UnitedStates but when selected only US sit on the screen field.