cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Issue

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

maciej_jarecki
Contributor
0 Kudos

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

Former Member
0 Kudos

Hi ,

Basically I am not good at java so could you please provide me the code.

Former Member
0 Kudos

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;
}
}

Former Member
0 Kudos

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;

}

}

Former Member
0 Kudos

Strange!! The code modified by you is not working in my system with the test data you provided here in this thread!! Am I missing something?? May be then actual scenario is bit different from whatever you explained here.. anyway if it is working for you then enjoy..

Answers (0)