cancel
Showing results for 
Search instead for 
Did you mean: 

Need UDF code

Former Member
0 Kudos

Hi All,

Source File

___________

Eno ename

____________

10 AA

20 BB

10 AA

30 CC

My requirement is need to identify the duplicate records at the mapping level.

Condition as below.

If eno and ename > 2 then status = "X"

else

Status = " "

Please provide me the JAVA UDF code for this.

Thanks,

Sagar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try a simple approach without using any UDF.

First Concatenate Eno & Ename by using Concat function and then follow below logic.

Eno+Ename>RemoveContext>Sort>SplitByValue(on value change)>Count-->IF (count > 2) map 'X' else map empty constant ' '.

You may have to do some tweaks but this logic will solve your problem easily.

Former Member
0 Kudos

Sarvesh, your approach is nice!

Usually, I spent less time to write an UDF than concatenate standard function (and lately... i almost forgotten to use it)... 😛

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi Spantaleoni

just remember as best practices,SAP recommend to try solve your requirement ussing standard functionality, and if its not possible use a UDF. one principal point it the mantaince or when PI system is upgraded for example

Hope Helps

Thanks

Rodrigo P-.

Answers (2)

Answers (2)

Former Member
0 Kudos

Another option would be

Eno+Ename>RemoveContext>Sort>SplitByValue(on value change)>CollapseContexts.

Former Member
0 Kudos

Another option would be

Eno+Ename>RemoveContext>Sort>SplitByValue(on value change)>CollapseContexts.

This will not work. Please read the question once again.

Former Member
0 Kudos

Hi,

Your correct, If i do that the duplicate records can supress insted of sending all duplicate records. But I am thingking how can we generate target file all the records with the status as below.

Eno Ename Status

10 AA M

20 BB S

10 AA M

30 CC S

Thanks,

Sagar.

Former Member
0 Kudos

Any suggestion please.....

Former Member
0 Kudos

Try something like this:

public void TEST(HashMap<int,String> INPUTTABLE,ResultList result,Container container){

HashMap<String,int> frequencymap = new HashMap<String,int>();

foreach(String a in INPUTTABLE) {

if(frequencymap.containsKey(a)) {

frequencymap.put(a, frequencymap.get(a)+1);

result.addValue("1");

break;

}

else{ frequencymap.put(a, 1); }

}