cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByIndex

Former Member
0 Kudos

Hi

My Requirement is.... i have to get the material numbers from the back end database and i have to add this material number to DropDown List dynamically.....

Once i select the number and click on the GO button all the information related to that material number has to display on front end page

please help me

Thanks & Regards

Ravi Shankar B

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Here i am getting data from R/3 System..... for this how to get the connection.... i know how to get the connection for oracle..sql. but i dont know how to do here.... i dont know the connection parameters.....how to know the JNDi name which has given in lookup() method

can u suggest me?

Thanks & Regards

Ravi shankar b

Message was edited by: RaviShankar B

Former Member
0 Kudos

Hi,

If you get values from R/3 System means you have to execute BAPI first. Then you will get values.

Kind Regards.

S.Saravanan

Former Member
0 Kudos

Thats what i am asking how to do that... how to get material id from the R/3 System.....

Thanks & Regrads

Ravi Shankar B

Former Member
0 Kudos

Hi ravi,

Sorry for my assumption that you are using database

IPrivate<view>.<node> Node node=wdContext.Node<node>;

node.invalidate();

First Execute the BAPI and find out the output node's size,say size;

then you can use any loop

for(int j=0;j<size;j++)

{

int matno=wdContext.node<Outputnode>().get<Outputnode

>ElementAt(i).get<Attribute>();

IPrivate<view>.<node> element ele=wdContext.Create<node>element

ele.set<attribute>(matno);

node.addElement(ele);

}

Regards,

Saravanan K

}

Former Member
0 Kudos

can u please tell me the entire process of how to find out the output node size

I have actually added my DropDownByKey element to my view page... now i want to just add material numbers dynamically which has taken from the R/3 system

Message was edited by: RaviShankar B

Former Member
0 Kudos

Hi Ravi,

Are you using Dropdownbyindex or Key?

You can find the size of outputnode by

int size=wdContext.node<BAPIOutputnode>.size();

I will give sample code,

int size=wdContext.nodeProductOutput().size();

Regards,

Saravanan K

Former Member
0 Kudos

Hai Ravi,

Create a model of type adaptive RFC model, here you give required information to connect to r/3

after wards add this model to controller,

add code like this,

wdContext.currentrequestXXXX.setXX();//give any inputs that reuire to execute abapi

wdContext.currentrequestXXXX.modelObject.execute();

wdContext.nodeResponse().invalidate();

int size=wdContext.nodeResult.size();//find out the size of result.

bind this result to dropdownbyindex Element.

regards,

Former Member
0 Kudos

Hi,

How to load the values using ResultSet and Statement....

help me...

Thanks & Regards

Ravi Shankar B.

Former Member
0 Kudos

Hi Ravi,

After getting the connection, name it as conn,

Statement st=conn.createStatement();

Resultset rs=st.executeQuery("Query");

IPrivate<View>.I<Context>Node mnode=wdContext.node<Context>();

mnode.invalidate();

while(rs.next()){

IPrivate<View> melement=wdContext.create<Node>Element();

melement.set<parameter>(rs.getInt("field in database"));

mnode.addElement(melement1);

}

P.S:

You can get the connection using

InitialContext initialContext = new InitialContext();

DataSource dataSource = (DataSource)initialContext.lookup("jdbc/Alias name");

java.sql.Connection conn = dataSource.getConnection();

Regards, Saravanan K

Joseph_BERTHE
Active Contributor
0 Kudos

Hello,

I assume that you have somewhere all Material information : ID and Desc

The below code deals with a DropDownByKey (I know it is not your request, but... have a look)

-


the shem you have to have in your mind is :

-----------


+

Key

value

-----------


+

AA11

Hammer

-----------


+

...

...

-----------


+

In your <b>context</b> :

-> <i>Material4DropDownByKey</i> type <i>String</i>

Your<b> initialization methode</b> :

<i>//Get access to data type instance to be modified at runtime

ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf("Material4DropDownByKey");

//Set valid values for this data type

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

values.put("AA11","Hammer");

(...)

wdContext.currentContextElement().setMaterial4DropDownByKey("AA11");</i>

Then map to your IUElement.

regards

Former Member
0 Kudos

Hi Ravi,

If you want store lot of information releated to material number then you can create more attributes to particular node. When ever you select a particular material number you will get releated information.

Like consider all properties are String.

Step 1;

Create one static node name is 'NodeA'

IWDNodeInfo multiplenode = multipleinfo.addChild("MultiNode" , null, true, false, true, true, false, true, null, null, null);

multiplenode.addAttribute("material no", "ddic:com.sap.dictionary.string");

multiplenode.addAttribute("material name", "ddic:com.sap.dictionary.string");

multiplenode.addAttribute("material price", "ddic:com.sap.dictionary.string");

multiplenode.addAttribute("material stock", "ddic:com.sap.dictionary.string");

Step 2:

Assign values for Dropdown

IWDNode node1 = wdContext.nodeNodeA().getChildNode("MultiNode", IWDNode.NO_SELECTION);

IWDNodeElement elem1;

for(int s=0;s<5;s++){

elem1 = node1.createElement();

elem1.setAttributeValue("materialno","no"+s);

elem1.setAttributeValue("materialname","name"+s);

elem1.setAttributeValue("materialprice","price"+s);

elem1.setAttributeValue("materialstock","stock"+s);

node1.addElement(elem1);

}

Step 3:

Inside Domodifyview create IWDDropDownByIndex UI Element and Bind it.

IWDDropDownByIndex dropDownList = (IWDDropDownByIndex)view.createElement(IWDDropDownByIndex.class, "drop");

IWDAttributeInfo info = wdContext.getNodeInfo().getChild("NodeA").getChild("MultiNode").getAttribute("roles");

dropDownList.bindTexts(info);

dropDownList.setWidth("100");

Finally add this Dropdown into container. Like this you can create more Dropdown and add action to the dropdown as dynamically.

Kind Regards,

S.Saravanan.

Former Member
0 Kudos

Hi Ravi,

First you have to load the number into dropdown by,

Load the values using Resultset and Statement,

Consider Resultset rs, and statement st,

IPrivate<View>.I<Context>Node mnode=wdContext.node<Context>();

mnode.invalidate();

while(rs.next()){

IPrivate<View> melement=wdContext.create<Node>Element();

melement.set<parameter>(rs.getInt("field in database"));

mnode.addElement(melement1);

}

then select the current dropdownelement and using that Query the database and store it in Resultset.

And display the format you want.

Regards,

Saravanan K

Former Member
0 Kudos

I suggest reading the book "Inside Web Dynpro for Java" by Chris Whealy (assuming you are using WD Java).

Armin