cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdown key

Former Member
0 Kudos

Hi Experts,

What is the difference between Dropdown key and Dropdown index?

Thanks,

P.Manivannan.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Manivannan,

The basic difference between the DDBKEY and DDBI is that if you bind the DDKEY to the context attribute at runtime the attribute will store the key displayed and DDBI's binded attribute will store the value.

What is important to know in this case is when to use them over each other.

Look using DDbyKey is preferable when you importing an RFC where the simple types are getting created at automatically and gets populated on a call so there is no work required from our side and also for dynamic changing values.

DDByIndex are more like showing a list on the UI and so are they populated an attribute of type list is binded and populated at runtime.More used for displaying the static data.

You can find out minor technical details associated with it in SAP Netweaver Documentation.

Regards

Amit

Message was edited by:

Amit Kesari

Answers (6)

Answers (6)

Former Member
0 Kudos

HI Manivannan,

For dropdown by Index, we will get the value as index based, from 0 to N-1.

So, we will use node in the context, to store these multiple values of dropdownby index.

ie.One context variable inside a node is bound to DropdownbyIndex.

We will add elements to this node, which will be the elements of DDbyIndex.

In contrast, for Dropdown by key, the values are stored as key-value pair (Similar to a HashMap). So only one context variable of type string is enough for dropdown by key. At runtime, we can put values to this context variable so that it can act like a HashMap. Also, we can define key-value pairs in dictionary at designtime , so that it can be bound to this DDbyKey context variable.

Regards

Fahad Hamsa

former_member751941
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi mani,

Dropdown by key:

here used for simple type Static Data's(creating "Enumeration TAB")

here Context Attribute is used

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/5c/1b76bc3da0504e8b535cf3e154eaa7/frameset.htm">DropDownByKey</a>

Dropdown by index

here used for Dynamic data's(creating Run time),

here context node is used

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/5c/1b76bc3da0504e8b535cf3e154eaa7/frameset.htm">DropDownByIndex</a>

Regards,

vino

Former Member
0 Kudos

Hi,

DropdownKey--> creating the simple type-> enumeration ,u can insert the datas into the dropdown box

DropdownIndex----> u have to write dynamic coding to insert the datas into the dropdown box

Former Member
0 Kudos

Hi,

Drop down by key contains values like(Approve) and this value "Approve" is mapped to a key value ("A"). These mapping is done using ValueSet

In case of drop down by index.. it only contains values which are indenfied by their index poisitions.

Let me know if you need code.

Thnaks

Avijit

Former Member
0 Kudos

hi friend,

please send some sample coding for this query

it is very useful for me

Advance Thanks,

Balaji

Former Member
0 Kudos

Hi Balaji,

Here is a sample code for DDBIndex(Place it in DoModifyView() method),

In this scenario, there is a node named 'Degree' in the context of 'Forum' View, which is bound to DDBIndex UI Element.

IPrivateForumView.IDegreeElement degelement1 = wdContext.nodeDegree().createDegreeElement();
degele0.setDegree("School");
wdContext.nodeDegree().addElement(degelement1);

IPrivateForumView.IDegreeElement degelement2 = wdContext.nodeDegree().createDegreeElement();
degele0.setDegree("UG");
wdContext.nodeDegree().addElement(degelement2);

IPrivateForumView.IDegreeElement degelement3 = wdContext.nodeDegree().createDegreeElement();
degele0.setDegree("PG");
wdContext.nodeDegree().addElement(degelement3);

OR

You can place the code for inserting elements to the node, into a loop, which can reduce the burden of coding.

For DDBKey, You have to just bind the DDBKey UI Element, to the corresponding context node, which has dictionary structure binding.

Regards,

Prabhakar.

Former Member
0 Kudos

hi Prabha,

Thanks for ur reply, In DDBK, i read in one reply, we use DDBK as hash map

do u have any sample coding for DDBK

pl send to me

Thanks.

Former Member
0 Kudos

Hi,

Context

-DDBKNode (node)

---Key (attribute)

---Value (attribute)

The selected.Key property of DropDownByKey is mapped to Attribute "Value"

IWDAttributeInfo atrInfo = wdContext.nodeDDBKNode().getNodeInfo().getAttribute("Value");

IModifiableSimpleValueSet ValueSet = atrInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

// ValueSet.put("Default","Select a value"); // if you want a default value

for(int i = 0; i < wdContext.nodeDDBKNode().size();i++)

{

ValueSet.put(wdContext.nodeDDBKNode().getDDBKNodeElementAt(i).getKey(), wdContext.nodeDDBKNode().getDDBKNodeElementAt(i).getValue());

}

Former Member
0 Kudos

Thank you so much for ur reply Shriram

Former Member
0 Kudos

Hi,

you can also use DDBI instead of DDBK provided the key and value attributes are under the same node.Only thing is their is a null value at the start of the DDBI.

Say you have context structure as

Context

-DDBKNode (node)

---Key (attribute)

---Value (attribute)

Then map "texts" property of DropDownByIndex to Attribute "Value" fo the node DDBKNode

In your action where you want to get the Key of the selected value in the dropdownbyindex

if(wdContext.nodeDDBKNode.getLeadSelection()==-1) // check if the null value of DDBI is selected

{// if the null value of DDBI is selected display a message

wdComponentAPI.getMessageManager().reportException("Error Message",false);

}

else

{

wdContext.currentDDBKNodeElement.getKey(); // this will give you the key of the selected value.

}

Former Member
0 Kudos

Hi all,

Thanks for your replies.

Regards,

P.Manivannnan

Former Member
0 Kudos

Hi,

DropDownByKey has a key associated with every value that is shown in the dropdown (key value pair) while DropDownByIndex has Index associated with every value of it.

When you get the lead selection in DDBI you get the index of the element where as in case of DDBK you get the key value of the element.

To populate values in the DDBK you need to modify the attribute and code yourself

where as in case of DDBI you associate the attribute with DDBI property.