Remove duplicate records in message mapping
Issue Statement: If there are duplicate records(identified by key field) in a message, send only one record to target system.
Input & Output Message Structure:
MT_Vendor
row
SupplierNumber
Field1
Field2
….
….
Logic: Create ‘row’ node only once for duplicate records. Suppress the other duplicate records.
Solution: Create a simple UDF, to suppress the subsequent duplicate records. I got the UDF code from SDN, when I was implementing the logic for a project 🙂
Message mapping:
UDF Code:
for (int i = 0; i < input.length; i++) {
int found = 0;
for (int j = 0; j < i; j++) {
if (input[i].equals(input[j]))
{
found = 1;
break;
}
}
if (found > 0) result.addSuppress();
else result.addValue(input[i]);
}
Simple and helpful
Simple solution that solved my problem. Cheers!