cancel
Showing results for 
Search instead for 
Did you mean: 

Needed UDF in Shabarish Vijayakumar's weblog

Former Member
0 Kudos

Hi,

In the Shabarish Vijayakumar's weblog

/people/shabarish.vijayakumar/blog/2005/08/03/xpath-to-show-the-path-multiple-receivers

1. I need code for the following UDFs

“ChkSum” and “AnyError”

and

2. how Constant (RDFILE) can be created ?

Thanks,

ss

Message was edited by:

s s

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

<b>For chkSum - </b>

Create a UDF [Enhanced Functions (Cache = Context)]

int totAmount=0;

for(int j=0;j<a.length;j++)

{

totAmount=totAmount+Integer.parseInt(a[j]);

}

if(totAmount==Integer.parseInt(b[0]))

result.addValue("0");

else

result.addValue("1");

<b>For AnyError - </b>

Create a simple function

if(a.equals("true") && b.equals("0"))

return "0";

else

return "1";

<i>2. how Constant (RDFILE) can be created ?</i>

>>>

in the Filename give the value as RDFILE

else if u r askin how to create a constant in the mapping logic use the constant function from the standard functions available (http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm)

Former Member
0 Kudos

Thank you very much Shabarish for your help.

Answers (3)

Answers (3)

Former Member
0 Kudos

hi

You can create constant RDFILE in this way

in functions( below left ) go to constants and select constant

double click it and set the value as RDFILE

Mudit

Former Member
0 Kudos

Hi Mudit,

I tried the code as advanced UDF but it gave me

<b><u>Source code has syntax error:</u></b>

C:/usr/sap/SXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapfc96f4b0a30f11dba64f001676478b29/source/com/sap/xi/tf/_RD_MM_.java:86: cannot resolve symbol symbol : variable amount location: class com.sap.xi.tf._RD_MM_ for(int i=0;i<amount.length;i++) ^

C:/usr/sap/SXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapfc96f4b0a30f11dba64f001676478b29/source/com/sap/xi/tf/_RD_MM_.java:88: cannot resolve symbol symbol : variable amount location: class com.sap.xi.tf._RD_MM_ totAmount=totAmount+Integer.parseInt(amount); ^

C:/usr/sap/SXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapfc96f4b0a30f11dba64f001676478b29/source/com/sap/xi/tf/_RD_MM_.java:90: cannot resolve symbol symbol : variable sum location: class com.sap.xi.tf._RD_MM_ if(totAmount==Integer.parseInt(sum[0])) ^

C:/usr/sap/SXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapfc96f4b0a30f11dba64f001676478b29/source/com/sap/xi/tf/_RD_MM_.java:97: cannot resolve symbol symbol : variable Input1 location: class com.sap.xi.tf._RD_MM_ if(Input1.equals("true") && Input2.equals("0")) ^

C:/usr/sap/SXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapfc96f4b0a30f11dba64f001676478b29/source/com/sap/xi/tf/_RD_MM_.java:97: cannot resolve symbol symbol : variable Input2 location: class com.sap.xi.tf._RD_MM_ if(Input1.equals("true") && Input2.equals("0")) ^

C:/usr/sap/SXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapfc96f4b0a30f11dba64f001676478b29/source/com/sap/xi/tf/_RD_MM_.java:98: cannot return a value from method whose result type is void return "0"; ^

C:/usr/sap/SXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapfc96f4b0a30f11dba64f001676478b29/source/com/sap/xi/tf/_RD_MM_.java:100: cannot return a value from method whose result type is void return "1";

what went wrong ?

Thanks,ss

henrique_pinto
Active Contributor
0 Kudos

The name of the variables arent been found.

Probably you defined them as "a" and "b"...

Also, please note that you need a

<i>

in the amount variable, inside first for of first UDF.

Regards,

Henrique.

Former Member
0 Kudos

hi;

did you take in the variable names as amount and sum in the first fn and Input1 andInput 2 in the second function.

Mudit

Former Member
0 Kudos

Hi

AnyError

if(Input1.equals("true") && Input2.equals("0"))

return "0";

else

return "1";

Mudit

Former Member
0 Kudos

Thanks Mudit, will try and update you

Former Member
0 Kudos

Hi;

Code for ChkSum

int totAmount=0;

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

{

totAmount=totAmount+Integer.parseInt(amount<i>);

}

if(totAmount==Integer.parseInt(sum[0]))

result.addValue("0");

else

result.addValue("1");

Mudit

Award Points if it helps