on 04-12-2011 1:58 PM
Hi All
I have a problem with mapping to identify the duplicate records in a source file.
Source File.
___________________
Eno Name
___________________
100 A
200 B
300 C
100 A
As per the above source file having one duplicate record with 100 emp so here my requirement is need to update the status at receiver side as below
_______________________
Eno Ename Status
_______________________
100 A M
200 B S
300 C S
100 A M
Please provide me the udf code if the requirement achive with userdefined function.
Thanks
Hi
Create UDF for All value in context
now sort your table that has been passed to UDF
that loop throuh each elelemnt of this table and if it deifrent that prevouse one than add value with
result.addValue(String value);
Hope it helps
BR
Maciej
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the mapping steps and udf code.
Concat Eno & Ename (keep the context of Eno & Ename to it's heigher level) >UDF>SplitByValue(each)--->Target.
While creating UDF set the Cache as "queue" and create the variable with name "var1".
int count = 0;
for(int i = 0; i<var1.length ; i++)
{
for(int j = 0; j<var1.length ; j++)
{
if( var1<i>.equals(var1[j]))
{
count = count + 1;
if (count > 1)
{
result.addValue("M");
count = 0;
break;
}
}
}
if( count == 1 )
{
result.addValue("S");
count = 0;
}
}
Hi ,
Thanks a lot for your help. It is working but it should has small correction needed for getting the actual result
int count = 0;
for(int i = 0; i<var1.length ; i++)
{
for(int j = 0; j<var1.length ; j++)
{
if( var1<i>.equals(var1[j]))
{
if (count > 1)
{
result.addValue("M");
count = 0;
break;
}
count = count + 1;
}
}
if( count == 1 )
{
result.addValue("S");
count = 0;
}
}
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.