cancel
Showing results for 
Search instead for 
Did you mean: 

UDF requirement

Former Member
0 Kudos

Hi Experts,

I have recently developed a IDOC (Invoice) to File interface.

I need a UDF code for the below requirement.

The requirement is to check (for all the occurrences) if E1EDP26/QUALF is 011; if yes then it has to check whether E1EDP26/BETRG equals FUEL or not. If any one occurrence of E1EDP26/BETRG when E1EDP26/QUALF is 011 has the value as FUEL then the output of the UDF should be true.

For example if E1EDP26/BETRG when E1EDP26/QUALF is 011 has seven occurances on source side then UDF should return true if atleast one or more occurrence of E1EDP26/BETRG when E1EDP26/QUALF is 011 has the value as FUEL. And should return false if none of the occurance has value as FUEL.

I dont think this can be achived using graphical mapping, can any one please send me complete code to achive the above. I am relatively new to PI without any JAVA knowledge.

Regards

Chandrika

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Chandrika,

Please try the following

int j = 0

for (int i=0;i<var2.length;i++) 

     if((var1[i].equals("011"))&&(var2[i].equals("FUEL"))) 

     { 

          j=j+1

          break

     } 

}


if(j>0

result.addValue("true"); 

else 

result.addValue("false");

Former Member
0 Kudos

Hi,

Check this UDF

Execution type: all values of a context

Input: var1, var2

int j = 0;

if(var1[0].equals("011"))

{

for (int i=0;i<var2.length;i++)

{

if(var2[i].equals("FUEL"))

{

j=j+1;
break;

}

}

}

if(j>0)

result.addValue("true");

else

result.addValue("false");

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Amith,

Thanks for your help, but the above code is not giving the required results.

my requirement is if E1EDP26/BETRG when E1EDP26/QUALF is 011 has seven occurances on source side then UDF should return true if atleast one or more occurrence of E1EDP26/BETRG when E1EDP26/QUALF is 011 has the value as FUEL. And should return false if none of the occurance has value as FUEL.

by using the above udf it is giving one false and one true.

i want only one true as result if  if atleast one or more occurrence of E1EDP26/BETRG when E1EDP26/QUALF is 011 has the value as FUEL.

To make it more clear; i will explain it with onec example; assume that i have 4 occurances on source side and only one has the value as FUEL, my requirement is the udf should return true since one of the occurance has value as FUEL.

but the UDF is giving three true and one false.

Please let me know how i get one true value.

Regards