on 07-27-2009 9:08 AM
Hi Experts,
I have created WD program which fetches data from R/3 using RFC. I am getting data in following way:
Pernr Name
1 Adam
2 Smith
3 Bob
I want to sort the data in following way:
Pernr Name
1 Adam
3 Bob
2 Smith
Please note that I am using the Name field to populate drop down UI element.I want the name to be sorted before it is used in drop down UI element.
How I can do so?
Regards,
Gary
Hi ,
You need to sort the node in which the data is stored is the following way :
wdContext.nodeOutput_dropdown().nodeIt_Apr_Id_Tab().sortElements
(
new Comparator()
{
public int compare(Object x, Object y)
{
String ax = ((IWDNodeElement) x).getAttributeValue("<element name in the node>").toString().toUpperCase();
String ay = ((IWDNodeElement) y).getAttributeValue("<element name in the node>").toString().toUpperCase();
if (ax == null)
{
return ay == null ? 0 : 1;
}
return ax.compareTo(ay);
}
}
);
Hope this solution will help you.
Thanks
Ritushree
Ritushree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gary,
Take all the name values into List object and apply
Collection.sort(List) method to sort the object.Now get the values from List by itearting it.
( Or ) DO webdynpro table Sortinga and get the vlaues.
Regards,
srikanth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gary,
Get the name values from the table in to List object.
List l=new List();
for(int i=0;i<wdContext.node<name>.size();i++)
{
l.add(wdContext.node<name>.get<name>ElementAt(i);getName());
}
pass this List object to sort method to sort the List.
Collections.sort(l);
NOw the List object will be sorted out.
Iterate the List to get the values.
Iterator i= l.iterator();
while(i.hasNext())
{
String str= (String)i.next();
}
here u can use the str value.
Regards,
srikanth
Edited by: Srikanth Thatipally on Jul 27, 2009 10:41 AM
Edited by: Srikanth Thatipally on Jul 27, 2009 10:44 AM
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
you can take it in a map and apply sort
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aishwarya,
How to do so? I am using collection:
The code is as below.
Regards,
Zname1_Md_name_Getlist_Input input = new Zname1_Md_name_Getlist_Input();
wdContext.nodeZname1_Md_name_Getlist_Input().bind(input);
input.setPi_Langu("EN");
try {
wdContext.currentZname1_Md_name_Getlist_InputElement().modelObject().execute();
} catch (WDDynamicRFCExecuteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
Collection NameFrom = new ArrayList();
Collection NameTo = new ArrayList();
for(int x=0; x<wdContext.nodePot_name().size(); x++){
IPublicCreate_travel_request_comp.IFromnamesElement from = wdContext.createFromnamesElement();
IPublicCreate_travel_request_comp.ITonamesElement to = wdContext.createTonamesElement();
from.setFromnames(wdContext.nodePot_name().getElementAt(x).getAttributeAsText("Landx"));
to.setTonames(wdContext.nodePot_name().getElementAt(x).getAttributeAsText("Landx"));
NameFrom.add(from);
NameTo.add(to);
}
wdContext.nodeFromnames().bind(NameFrom);
wdContext.nodeTonames().bind(NameTo);
int index = 0;
for(int x=0; x<wdContext.nodeFromnames().size(); x++){
if(wdContext.nodeFromnames().getFromnamesElementAt(x).getFromnames().equalsIgnoreCase("saudi arabia")){
index = x;
}
}
wdContext.nodeFromnames().setLeadSelection(index);
wdContext.nodeTonames().setLeadSelection(index);
return true;
change the following code segment:
//Collection NameFrom = new ArrayList();
//Collection NameTo = new ArrayList();
ArrayList namesList = new ArrayList();
for(int x=0; x<wdContext.nodePot_name().size(); x++){
IPublicCreate_travel_request_comp.IFromnamesElement from = wdContext.createFromnamesElement();
IPublicCreate_travel_request_comp.ITonamesElement to = wdContext.createTonamesElement();
from.setFromnames(wdContext.nodePot_name().getPot_nameElementAt(x).getLandx());
to.setFromnames(wdContext.nodePot_name().getPot_nameElementAt(x).getLandx());
//from.setFromnames(wdContext.nodePot_name().getElementAt(x).getAttributeAsText("Landx"));
//to.setTonames(wdContext.nodePot_name().getElementAt(x).getAttributeAsText("Landx"));
NameFrom.add(from);
NameTo.add(to);
}
*Collections.sort(from);*
*Collections.sort(to);*
Edited by: Aviad Levy on Jul 27, 2009 10:55 AM
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.