on 04-06-2011 6:39 AM
Hi All,
I am looking for Java UDF code for below requirement.
Source file as below.
Eno Ename
1 A
2. B
3. C
1 A
1 A
The source file having the duplicate record with Emp no 1 and Ename A. So I want to set the status at the receiver side as below.
Eno Ename Status.
1 A M
2. B S
3. C S
1 A M
1 A M
The employe no 1 repeted multiple times so that i want to set the status as " M" and If the record no duplicates the status would be "S".
Thanks,
SagarK
one of the UDF you can try is:
String[] x = {"1", "2","3","1"}; -- input "Eno" to the UDF
String[] y = {"A", "B","A","A"}; -- input "EName" to the UDF
int lx = x.length;
int ly = y.length;
String status = "";
for (int cnt = 0;cnt < lx; cnt ++){
for (int cnt2 = 1;cnt2 < lx; cnt2 ++){
if((x[cnt] == x[cnt2]) && (y[cnt] == y[cnt2])){
status = "Y";
}
else{
status = "N";
}
}
if(status == "Y"){
result.addValue("M")
}
else{
result.addValue("S")
}
}
You need to be sure on how will you deal with:
1.
Eno Ename
1 A
1 B
2.
Eno Ename
1 A
1 A
In first case(if it is to be considered as "M") UDF needs to be modified.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sagar,
This could be easily achieved through use of Count function in message mapping.
Regards,
Sanjeev.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.