cancel
Showing results for 
Search instead for 
Did you mean: 

help for java code

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member204873
Contributor
0 Kudos

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.

Answers (1)

Answers (1)

former_member194786
Active Contributor
0 Kudos

Hi Sagar,

This could be easily achieved through use of Count function in message mapping.

Regards,

Sanjeev.