on 05-15-2007 9:15 AM
Hi Group,
In one of my Message Mapping (File to File scenario) I want to sort the reference number field,In which reference number fields have value 'REF' I want to keep them
in the Last,can any body suggest(in this Reference Number some of them contains REF and all others are numbers),Please suggest.
Hi,
Did you see my last post.It's working fine.
Cheers!
Samarjit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi swabap,
ArrayList arr = new ArrayList();
for(int i=0;i<a.length;i++){
arr.add(a<i>);
}
List listA = arr.subList(0,arr.size());
Iterator itr = listA.iterator();
Collections.sort(listA);
while(itr.hasNext()){
result.addValue(itr.next()+"");
}
this code work in xi.
Before that you should import java.util.*;
Cheers!
Samarjit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
ArrayList arr = new ArrayList();
for(int i=0;i<a.length;i++){
arr.add(a<i>);
}
Iterator itr = arr.iterator();
List listA = arr.subList(0,arr.size());
Collections.sort(listA);
Iterator itr = listA.iterator();
while(itr.hasNext()){
return.addValue(itr.next()+"");
}
Please check this code i hope it will work.
Assume "a" is the String array coming from method as a parameter.
Cheers!
Samarjit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If code is still giving error..try with this.
Iterator itr = a.iterator();
List listA = a.subList(0,a.length);
Collections.sort(listA);
Iterator itr = listA.iterator();
while(itr.hasNext()){
return.addValue(itr.next()+"");
}
Assume "a" is the array coming from method as a parameter.
Cheers!
Samarjit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Did you check the Sort function under the node functions?
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
<i>Sorts all values of the multiply-occurring inbound field I within the existing or set context. The sorting process is stable (the order of elements that are the same is not switched) and it sorts the values in O(n*log(n)) steps. Using the function properties, you can specify whether values are to be sorted numerically or lexicographically (case-sensitive or non case-sensitive) and in ascending or descending order.</i>
Regards
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
refer: /people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-xi-30-sp13
or u can use a udf....check with code (wrt to other thread):
Vector vID = new Vector();
for (int i=0; i<a.length; i++) {
if (!vID.contains(a)) vID.add(a);
}
Collections.sort(vID);
for (int i=0; i><vID.size(); i++) {
result.addValue((String)vID.get(i));
}
Hi,
/****UDF****/
ArrayList arr = new ArrayList();
arr.add("1909138700012");
arr.add("1947991300010");
arr.add("REF");
arr.add("1947991300045");
arr.add("1947991300067");
arr.add("REF");
arr.add("REF");
Iterator itr = arr.iterator();
List listA = arr.subList(0,arr.size());
Collections.sort(listA);
System.out.println("New Sorted List : " + listA);
/********/
return listA in form of String.
Output:
New Sorted List : [1909138700012, 1947991300010, 1947991300045, 1947991300067, REF, REF, REF]
Cheers!
Samarjit
Message was edited by:
Samarjit Dey
Hi swabap,
Create UDF of queue mapping there String a[] will come automatically.
then put my code like
ArrayList arr = new ArrayList();
arr = a;
Iterator itr = arr.iterator();
List listA = arr.subList(0,arr.size());
Collections.sort(listA);
Iterator itr = listA.iterator();
while(itr.hasNext()){
return.addValue(itr.next().toString());
}
Cheers!
Samarjit
Message was edited by:
Samarjit Dey
Hi Samrajith,
do I need to add any imports because I am getting the following Erros.
<b>
ile_.java:3250: incompatible types found : java.lang.String[] required: java.util.ArrayList arr = a; ^ /usr/sap/XD1/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Map48517d4002d211dcc92a0003bae4e42a/source/com/sap/xi/tf/_FIle_to_File_.java:3254: itr is already defined in refsort$(java.lang.String[],com.sap.aii.mappingtool.tf3.rt.ResultList,com.sap.aii.mappingtool.tf3.rt.Container) Iterator itr = listA.iterator(); ^ /usr/sap/XD1/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Map48517d4002d211dcc92a0003bae4e42a/source/com/sap/xi/tf/_FIle_to_File_.java:3256: cannot return a value from method whose result type is void return(itr.next().toString()); ^ 3 errors().toString()); ^ 3 errors
</b>
Hi Samrajith,
I included the below objects in imports fiels in UDF (at the top)
<b>
java.util.Collections;java.util.List;java.util.Iterator;java.util.ArrayList;
</b>
still I am getting the Error
<b>
usr/sap/XD1/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Map8848509002e111dcc9c60003bae4e42a/source/com/sap/xi/tf/_FIle_to_File_.java:3261: cannot resolve symbol symbol : method iterator () location: class java.lang.String[] Iterator itr = a.iterator(); ^ /usr/sap/XD1/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Map8848509002e111dcc9c60003bae4e42a/source/com/sap/xi/tf/_FIle_to_File_.java:3262: cannot resolve symbol symbol : method size () location: class java.lang.String[] List listA = a.subList(0,a.size()); ^ /usr/sap/XD1/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Map8848509002e111dcc9c60003bae4e42a/source/com/sap/xi/tf/_FIle_to_File_.java:3264: itr is already defined in contrasort$(java.lang.String[],com.sap.aii.mappingtool.tf3.rt.ResultList,com.sap.aii.mappingtool.tf3.rt.Container) Iterator itr = listA.iterator(); ^ /usr/sap/XD1/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Map8848509002e111dcc9c60003bae4e42a/source/com/sap/xi/tf/_FIle_to_File_.java:3266: cannot return a value from method whose result type is void return addValue(itr.next().toString()); ^ 4 errors
</b>
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.