cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdown list for a field coming from R/3 through RFC

Former Member
0 Kudos

Hello Everyone,

We have a BAPI coming from the Backend through RFC. We created a form and we want to make on field as a Drowndown list with 5 to 6 values in it on the webdynpro View. But, the field that is coming from the backend is just an inputfield. Could anyone help me how to acheive this. I would appreciate your help.

Regards,

Gopal.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

You can follow the below mentioned steps to populate the dropdown :

Create an ui element dropdownbykey and create an value attribute and bind it to the dropdown ui element.

IWDAttributeInfo attrInfo = wdContext.getNodeInfo().getAttribute(IPrivateUnmatchedProdEditHistoryView.IContextElement.<attribute name>);

ISimpleTypeModifiable msType = attrInfo.getModifiableSimpleType();

IModifiableSimpleValueSet valueSet = msType.getSVServices().getModifiableSimpleValueSet();

// execute the R3 RFC

valueSet.put("Please Select","");

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

{

String hqIdAndName = wdContext.get<nodename>ElementAt(i).get<Element name>() + ", " + wdContext.get<nodename>ElementAt(i).get<Element name>();

valueSet.put(wdContext.get<nodename>ElementAt(i).get<Element key>()

,hqIdAndName);

}

Hope this will help you.

Thanks

Ritushree

Former Member
0 Kudos

Hi,

i hope when u have applied template and selected a model attribute, u have changed the Editor property to dropdown by key or drop down by index. if not, try doing this.

Regards,

Satya.

Former Member
0 Kudos

Hello,

The Backend field is just an input field but has not got any dropdown values. So, even if I select a Dropdown while I select Apply template I will get an empty list. Because the Dictionary type of the model datatype has not got anything in the enumeration as it is just an input fields.

Regards,

Gopal.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Christoph,

Your code will only work if the field in the backend has got some values in it. But, my backend field is just a inputfield. But, on the webdynpro side I want to give a choice of my own choice in the dropdown. I think this makes my question more clear. let me know if I am not clear. I would appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

Your requirement is if only one value coming from backend like in list of status only Active is coming from backend then you want to add addtional status at front end like "InActive, Completed, Not Completed etc...". Correct me if i am wrong?

If you use Dropdown by index:

Take one value node as below

TestNode:

-


> StatusAtt (value attribtue of type string).

Now first append the value which is coming from backend(in some model node) to this node:

IPrivateTestNode.ITestNodeElement element=wdContext.createTestNodeElement();

element.set(wdContext.currentStatusModelNode().getStatus());

wdCotnext.nodeTestNode().addElement(element);

After this add the remaining status which you want to insert at front end:

for(int iCount=0;iCount<3;iCount++)

{

IPrivateTestNode.ITestNodeElement statusElement=wdContext.createTestNodeElement();

if(iCount==0)

statusElement.setStatus("InActive");

else if(iCount==1)

statusElement.setStatus("Completed");

else if(iCount==2)

statusElement.setStatus("NotCompleted");

wdCotnext.nodeTestNode().addElement(statusElement);

}

If you use Dropdown by key:

For DropDownByKey UI element you need create one context attribute like "Statu" and you need to bind the type of this attribute to one simpletype. For this you need to create a simple type in the below location:

Go to your DC -> Dictionaries -> LocalDictionaries ->Data Types -> Simple Tytpes

Your simple type have a enumeration, when you call the method put of IModifiableSimpleValueSet, this means that you are populating the enumeration. The first parameter is a key, and the second is a description of enumeration.

IModifiableSimpleValueSet rep = wdThis.wdGetContext().getContext().getModifiableTypeOf("Status").getSVServices().getModifiableSimpleValueSet();

Now first append the value which is coming from backend(in some model node) to this node:

rep.put("A", wdContext.currentStatusModelNode().getStatus());

After this add the remaining status which you want to insert at front end:

for(int iCount=0;iCount<3;iCount++)

{

if(iCount==0)

rep.put("I", "InActive");

else if(iCount==1)

rep.put("C", "Completed");

else if(iCount==2)

rep.put("N", "NotCompleted");

}

Regards,

Charan

Former Member
0 Kudos

Hi Sri,

I don think you understood my requirement properly. Well, the model attribute coming from the Backend has not got any fixed values in it. It is checking the values from a checktable. So, the Model attribute in the webdynpro side is just an input field with no values in the enumeration tab of the Data type. But I want to give a dropdown box on the front end. Is this possible or not?

Does this make my requirement clear.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

"Model attribute in the webdynpro side is just an input field with no values in the enumeration tab of the Data type"

The meaning of this sentence is you have binded this model attribute to one InputField UI element at WebDynpro side right?

If yes how many values this model attribute contains (returned by bapi)?

If it contains only single value?

If you dont want to show this single value in InputField you can bind this to DropDownByIndex. But only one value will be displayed. If there is only single value why do you want to show it in on DropDownByIndex?

If it contains multiple values?

You can bind this model attribute to DropDownByIndex to show these multple values in the dropdown.

If it contains only single value and you want to append some more vaues?

Then follow the procedure explainded by me.

Regards,

Charan

Former Member
0 Kudos

Hi Charan,

The model Attribute is linked to a Search help and Check Table (i.e it has got quite a few values on the back end). But, on the Webdynpro side it only allows you input a value but not to select from a list.

The Datatype that the model Attribute is Bind to has got the "Builtin-type" as "String" and in the Enumeration Tab is empty with no values and description in it.

When I have implemented you code to the Model Attribute it is throwing a "null pointer exception".

Regards,

Gopal.

Former Member
0 Kudos

Hi,

You mean to say you are getting only one value instead of 5/6 values from backend. Your bapi should return 5/6 values to show 5/6 values in dropdownlist. Can you explain clearly?

Regards,

Charan