on 09-20-2016 4:25 PM
Dear experts,
Interface : IDOC --> JDA
before sending to JDA, there is another mapping to check duplicates in the same context.
As per screen,an item should check the duplicates in the context of the articles and trigger out the same but output comes in reverse order.
based on this logic, output is coming in reverse order, so inserting wrong values in JDBC table. please advise me code.
ArrayList aList = new ArrayList();
int j = 1;
for(int n=0; n<var1.length; n++)
j = n;
aList.add(var1[j]);
result.addValue(var2[j]);
for(int i=j-1; i>-1; i--){
if(aList.contains(var1[i])){
continue;
}
else{
aList.add(var1[i]);
result.addValue(var2[i]);
}
}
Hi, Deva!
You can use this code for removing duplicates from "var1" input queue.
LinkedHashSet<String> varList = new LinkedHashSet<String>(Arrays.asList(var1)); |
for (Iterator<String> iterator = varList.iterator(); iterator.hasNext();)
result.addValue(iterator.next().toString()); |
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deva,
Here is some information on some of the easiest stuff you can do regarding set operations - Set Interface
I'm not clear what you are doing with the duplicates but the method retainAll gives the intersection. However, if you are doing something that is specific to indices which may be the case since you mentioned context then I would suggest continuing with the index approach and refining the UDF code which you have included.
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy,
Yes, I am familiar with the concept but more unclear because the original post doesn't give enough details of what is expected for duplicates - specifically does it have to be only duplicates at any certain index (context) or duplicates across the whole set. For instance, if the two collections are A, B, C, D & A, B, C, c, D does that mean that D will not be marked as a duplicate? The post mentions context so in the case of the first set D is at index 3 and in the case of the second set it's at index 4 which would end up being different contexts altogether. As the saying goes the devil is in the detail but at the moment I only see halos. 😛
The LinkedHashSet has its own determination of the "intersection" with retainAll so I would merely use that instead of iterating the set on my own.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deva,
As per the screenshot if you want to remove the duplicate values from the field 'ITEM' then you can use the below UDF:
UDF type: Context
input: ITEM as a string
----------------------------------
ArrayList al = new Arraylist();
for(int i =0;i<ITEM.length();i++){
if(!al.contains(ITEM[i])){
al.add(ITEM[i]);
}
}
for(int j=0; j<al.size();j++){
result.addValue(al.get(j).toString());
}
-----------------------------------------------
Hope this will help you to remove the duplicates from the context.
Regards,
Suman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Deva,
Your requirement is to remove the duplicate values?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
67 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.