cancel
Showing results for 
Search instead for 
Did you mean: 

Populate data in dropdown

Former Member
0 Kudos

Hi All,

I am trying to populate values in dropdown by calling

BAPI. I have only one view in my applicaiton.

I created a model in custom controller and bind it to the model.

I defined the context (model node) in view controller same stucuture in custom controller and mapped the context between view controller and custom controller.

Model node

Zemployee2_Input

Output

TEmployee

Empname

Empno

Value attribute

empCode

I created a Template( table) and bind with the view context.

When I deployed the application, the table was displaying 32 records.

I have a problem to populate values in the dropdown.

I created value attribute called empCode in View contr.

I bind the attribute to the value property of dropdown

called dropdownEmployee.

issue#1:

int nodeSize = wdContext.nodeZemployee2_Input().size();

In runtime

nodeSize has 1.

But it supposed to have 32.

issue#2:

((IPublic<controller_name>.I<node_name>Element)(wdContext.node<node_name>().getElementAt(i))).get<attribute_name>());

What is get<attribute_name> ?

As per my model nodes,

I wrote this code like,

((IPublicTestCustom.IZemployee2_InputElement)(wdContext.nodeOutput().getElementAt(i))).?

after this,

Intellisense gives me 3 options to select,

getAttributeAsText();

getAttributeValue();

getClass();

Where do i select get<attribute_name> ?

Please give me a solution for this.

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

sridhar_k2
Active Contributor
0 Kudos

Hi,

int nodeSize = wdContext.nodeZemployee2_Input().size();

As Table showing 32 records, dropdownlistbox also show the same records. Have bind the table to same node or different one?

I have pasted code to you, which is working fine with me. try to make use of it.

Create a context Variable in your View with empcode.

empCode - whichever you want to see in the DropDownListByKey.

IContextElement contextElement = wdContext.currentContextElement();

IWDNodeInfo nodeInfo = wdContext.getNodeInfo();

IWDAttributeInfo dateAttributeInfo = nodeInfo.getAttribute(contextElement.empCode);

IModifiableSimpleValueSet dropValueSet = dateAttributeInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

String empCodeTxt=null;

//Gives the Size of the List, which is coming from Model

int nodeLength = wdContext.node<BAPIList>().size();

for (int i = 0; i < nodeLength; i++) {

// Gives the Value, Which you want to show in Drop Down List Box.. Change it according to your need.

empCodeTxt=String.valueOf(((IPrivate<viewname>.I<BAPIList>Element)(wdContext.node<BAPIList>().getElementAt(i))).get<Parameter>());

dropValueSet.put(empCodeTxt, empCodeTxt);

}

Regards,

Sridhar

former_member182372
Active Contributor
0 Kudos

Hi Tiruna,

First check same solved problem

Issue#1:

int nodeSize = wdContext.nodeZemployee2_Input().size();

returns 1. And this is expected because there is only one instance of executable model class. 32 is number of elements in some Output`s node children (can`t say exactly because don`t know your model hierarchy). it is result of RFC invocation.

Issue#2:

<attribute_name> is the name of your context attribute under <node_name> name. For example - Empname nad Empno are attributes names.

getAttributeAsText will return String representation of attribute value.

getAttributeValue will return original Object. You need to cast it to appropriate class.

I would suggest you to use types access, like:

wdContext.node<node_name>().getOutputElementAt(i))).getEmpname()

For this you need to check node`s property typedAceess.

Best regards, Maksim Rashchynski.