cancel
Showing results for 
Search instead for 
Did you mean: 

Populating a dropdown list box from from a RFC/web service call

Former Member
0 Kudos

Hello All,

So far all the samples that I have on dropdown listboxes pulls their values from the Simple Type Enumeration table. Howvever, If i will like to populate the dropdown listbox with returned values from an imported model, does anyone have any documentation on how this may be achieved ? Thank you.

from

Kwok Wei

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

If u want to populate the Values in DropDown from RFC call u can use the following code

IWDAttributeInfo ainfo = wdContext.node<<NodeName>>().getNodeInfo().getAttribute("<<Value Attrib that is bounfd to the Drop Down>>");

ISimpleTypeModifiable st = aiinfo.getModifiableSimpleType();

IModifiableSimpleValueSet vs = st.getSVServices().getModifiableSimpleValueSet();

for(int i=0;i<wdContext.node<<Ur Table Parameter Name>>().size();i++)

{

vs.put(Key,Value}

}

The Above code is for Drop Down by Key

For Drop Down By Index

for(int i=0;i<wdContext.node<<Table Paramter>>().size();i++)

{

IPrivateFinancingPlanView.I<<NodeElement>> prodElement = wdContext.create<<Node Element>>();

prodElement.set<<Value Attribute Bound to drop Down>>(wdContext.node<<Table Paramter>>().get<<Table Paramter>>(i).getDescription());

<<Parent Node Element>>.node<<Child Node>>().addElement(<<Child Node Element>>);

}

Wishes

Krishna kanth

Message was edited by: krishna kanth

Former Member
0 Kudos

Hello All,

I tried out the code snippets as suggested (most of the sample appears to be suggesting the same thing except for VS). However, the result was not exactly what I was looking for.

The dropdown listbox did not contain the items as expected. All I can get in is the first item. The remaining 2 items are missing.

I believe this is where I went wrong :

valueSet.put(wdContext.currentContextElement().getSeatTypes(),

wdContext.currentResultElement().getPreferenceInformation());

The getPreferenceInformation contains "Any", "Aisle" and "Window".

Any help ? Thank you.

from

Kwok Wei

Former Member
0 Kudos

Hi,

You are getting the current element only.

You have to get all the elements.

for(int i =0;i<wdContext.node<name>.size();i++)

{

valueSet.put(wdContext.node<name>().get<nodename>elementat(i).getSeatTypes(),

wdContext.node<name>().get<nodename>elementat(i).getPreferenceInformation());

Regards

Bharathwaj

Former Member
0 Kudos

Thanks Bharathwaj. It you jus solved my problem.

Former Member
0 Kudos

Hi Bhartwaj

I am trying to use the below given code for populating drop down by key

from table paramenter of my bapi.

IWDAttributeInfo ainfo = wdContext.nodeZbfm_Ar_F4_Input().nodeTb_Cmpcode().getNodeInfo().getAttribute("Bukrs");

ISimpleTypeModifiable st = ainfo.getModifiableSimpleType();

IModifiableSimpleValueSet vs = st.getSVServices().getModifiableSimpleValueSet();

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

{

vs.put(wdContext.nodeZbfm_Ar_F4_Input().nodeTb_Cmpcode().getElementAt(i).getAttributeValue("Bukrs"), wdContext.nodeZbfm_Ar_F4_Input().nodeTb_Cmpcode().getElementAt(i).getAttributeAsText("Bukrs"));

}

which is giving me error that " com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(F4compoView.Zbfm_Ar_F4_Input.Tb_Cmpcode.Bukrs): must not modify the datatype of a mapped attribute

at com.sap.tc.webdynpro.progmodel.context.MappedAttributeInfo.getModifiableSimpleType(MappedAttributeInfo.java:117)

at com.sap.bhpb.comp.F4compoView.wdDoInit(F4compoView.java:122)

at com.sap.bhpb.comp.wdp.InternalF4compoView.wdDoInit(InternalF4compoView.java:139)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)

... 33 more"

Thanks & Regards

Visalini

Former Member
0 Kudos

Hi all,

In my ESS application, I am having the same code snip as all discussed above. But, what I need is to populate a default value in dropdown list.

Say I am having (Approve, Reject, Resubmit) as items to be populated in dropdown list. Here I need 'Resubmit' as default value, whereas I am getting 'Approve' as default value.

Any help on this?

Thanks & Regards,

Raj

Former Member
0 Kudos

Hi Raj

1.Say u r having a simple type(sampletype) of enumeration with values -Approve, Reject, Resubmit

2.and a context element sample under root of the simple type sampletype created above.

3.u r having a dropdown UI in u r view which is binded with context element sample.

4.then the following code sets to required value.

wdContext.currentContextElement().setSample("Resubmit");

is this u want?

Thanks

Visalini

Former Member
0 Kudos

Hi,

Thanks for your reply. But here I am getting the values from model. I am not creating any local simple types.

Any help in this regard.

Thanks,

Raj.

Former Member
0 Kudos

same way set for current node element

wdContext.current<bapinodename>Element.setSample("Value");

Answers (2)

Answers (2)

Former Member
0 Kudos

Bind the dropDownbyindex to a nodeattribute where the node has a cardinality of 0:n or 1:n

If you want to use dropDownbyKey then you can populate it dynamically as follows

IwdAttributeInfo info=wdContext.node<nodename>().getnodeInfo().getAttribute(<attribute name>);

IsimpleTYpeModifiable st=info.getModifiableSimpleType();

IModifiableSimpleValueSet sv=st.getSVServices().getModifiableSimpleValueSet();

then you can input values

sv.put(Object,String Key);

Former Member
0 Kudos

Please check this

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/tutorial on accessing the car rental web service.htm

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/tutorial on context programming and data binding.htm

If you want to display the values returned by different webservice calls, then create a ValueNode and ValueAttribiute inside and copy the values into this.

Please refer to context perogramming for this.

Just bind the dropdownByIndex to the value node to see the values.

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

Former Member
0 Kudos

hello,

if u want to populate values using a DropDownByKey UIE u may use this code. also this is the way to dynamically populate a dropdown box.

IWDAttributeInfo attinfo = wdContext.getNodeInfo().getAttribute("attribute_name");

ISimpleTypeModifiable modinfo = attinfo.getModifiableSimpleType(); IModifiableSimpleValueSet valset = modinfo.getSVServices().getModifiableSimpleValueSet();

for(i=0;i<10;i++)

{

valset.put("key","value");

}

now extract the value from an outer source like RFC or Database and populate it.

regards,

Piyush.

Former Member
0 Kudos

Thanks everyone for your kind inputs. I shall try out the codes and post my results.

Former Member
0 Kudos

Wheel reinvention never stops.

import com.sap.tc.webdynpro.progmodel.api.WDValueServices;
/*...*/
final IWDNode nMySource = wdContext.myRfcNode();
final IWDNodeInfo niMySource = nMySource.getNodeInfo();

WDValueServices.createBoundValueSet
(
  wdContext.myTargetNode().getNodeInfo().getAttribute("AttrSelectedKeyInTarget"), 
  nMySource, 
  niMySource.getAttribute("RfcAttrForKey"), 
  niMySource.getAttribute("RfcAttrForValue"), 
);

VS