on 10-19-2012 2:33 PM
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
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");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.