cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Check the duplicates in context in mapping

deva_gembali2
Participant
0 Kudos
1,257

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]);

}

}

View Entire Topic
suman_sourabh
Participant
0 Kudos

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