cancel
Showing results for 
Search instead for 
Did you mean: 

How to Set a DropDownByIndex

Former Member
0 Kudos

Hello All,

I need to set a DropDownByIndex using values that comes from a Bapi. Actually I load the DropDownByIndex using a Context structure, but would like to set the selection according to the Bapi value of the field.

For example

My DropDownByIndex include these values:

US USA

GT UK

CA Canada

So if I receive from the Bapi GT I should show in the DropDownByIndex UK.

I saw the documentation to set the DropDownByIndex using the index, but I would like to know if it’s possible to do it in this way.

Thanks in advance

Alexis

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Alexis:

This link to a tutorial explains you, that you need, it´s also a tutorial of DropDown in Web Dynpro

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/value help in web dynpro applications.pdf

Good luck!!!

Regards

Joshua

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Following the code snippet which may help you out.

Create a context

Node Country

Element CountryName

Create a hash map

HashMap hm = new HashMap();

iterate thrugh the node and populate the hash map.

ITestController.ICountryElement element = wdContext.createCountryElement();

IWDAttributeInfo wdAtrrInfo = wdContext.nodeCountry().getNodeInfo().getAttribute(IPublicTestController.ICountryElement.SELECTED_COUNTRY_ID);

ISimpleTypeModifiable myType=wdAtrrInfo.getModifiableSimpleType();

IModifiableSimpleValueSet values=myType.getSVServices().getModifiableSimpleValueSet();

if(hm != null)

{

Iterator objIterator = hm.keySet().iterator();

while(objIterator.hasNext())

{

String Key = objIterator.next().toString();

String Value = hm.get(Key).toString();

values.put(Key,Value);

}

}

wdContext.nodeRootID().addElement(element);

wdContext.currentRootIDElement().setSelectedRootID("GT");

Regards

Ayyapparaj

Former Member
0 Kudos

Hi All,

The problem is that I have the values in a Model Node which contains the result of the Bapi with the list of Countries, so how can I fill the dropdownlist from this context structure.

Regards,

Alexis

Former Member
0 Kudos

Alexis,

If you want to find the value by the key, you need to use the drop down by key. But to do that you need to populate a simple type with the key/value pairs. When the list is already in a node, I find it is easier to use the drop down by index and bind it to the node attribute you want displayed. Then you can get the selected index of the node and get to the selected element that way.

-Cindy

Former Member
0 Kudos

Hi,

Set the <b>texts</b> property of the Dropdown byindex to

the model attribute which gives the list of countries you wanted to get displayed in the dropdown.

Hope this helps.

Regards,

Rathna.

Former Member
0 Kudos

Hi All,

The problem is that I'm havings the values in a Model Node where I have the list of Countries, so how can I fill the dropdownlist from the structure.

Regards,

Alexis

Former Member
0 Kudos

Iterate through the node elements until you find the index of the "GT" entry, set the lead selection of the node to this index.

Armin

vijayakhanna_raman
Active Contributor
0 Kudos

Hi Alexis,

I think u cant do so in DD by index. It will display the value in the DD and what ever u select it

will get displayed. If the values that comes from a Bapi

is like key and value, then u can Dynamically assign a simple data type Simple Type to a value attribute at runtime, Bind it to a Input Field, this will return u only the key ,since u want to display the text, it can be achived by Calculated Context Attribute.

Check this link for more infohttps://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/yet another evs valuehelp - showing display texts for keys.article

Regards,

Vijayakhanna Raman