cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Code Required

Former Member
0 Kudos

Hi Experts,

i have the following requirement i had done this using graphical any way i am trying to write the UDF for the same.I am unable to complete this.Can anybody guide me to complete this.

Reuirement is as :- I have two inputs as a and b and need to implement the logic as X = (((a)/((b/a)100)+100)((b/a)*100))

Thanks in Advance

Abhijit

Edited by: ABHIJIT DAPTARY on Mar 18, 2008 5:48 PM

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Abhijit,

If you are getting floating point numbers (ex 123.45) in a or b then try this udf:

public String calculate(String a,String b, Container container){

float aa=Float.parseFloat(a);

float bb=Float.parseFloat(b);

return String.valueOf((aa/((bb/aa)100)+100)((bb/aa)*100));

}

Regards

Sankar Choudhury

Former Member
0 Kudos

Hi avijit,

make an UDF with two argument checking the value option and paste the following code;

int x,y,z,m,n,o,p,r;

x=Integer.parseInt(a);

y=Integer.parseInt(b);

m= y/x;

n=m*100;

r=x/n;

o=r+100;

p=o*n;

String str= new String();

str=new Integer(p).toString();

return str;

In case if the numbers are floating no then just write float instead int/Integer.

Regards,

Arijit

p.s: please reward point if useful.

Former Member
0 Kudos

Hi Abhijit,

Paste this line of code :

return String.valueOf((a/((b/a)100)+100)((b/a)*100));

Regards

Sankar

Former Member
0 Kudos

Hi,

As told my swarup you can do it by dividing it into two expressions.Here is the complete code on how to typecast the string and use it in XI.

Public void test(String a,String b){

float c=Float.parseFloat(a);

float d=Float.parseFloat(b);

float B,C,D;

B=(d/c)*100;

C=(c/B)+100;

D=C+B;

return(D+"");

}

Thanks,

Bhargav.

Note:Award points if found useful

Former Member
0 Kudos

HI,

The expression X = (((a)/((b/a)100)+100)((b/a)*100))

can be split-up as two expressions

A = ((aa)/(b100))+100

&&&

B=(b/a)*100

Please find here with you the UDF code

You need to convert the a and b to float type.

float c,d;

c= Float.parseFloat(a);

d= Float.parseFloat(b);

float A, B;

A = ((cc)/(d100))+100;

B=(d/c)*100;

return(String.valueOf(A*B));

Thanks

Swarup

Edited by: Swarup Sawant on Mar 18, 2008 1:29 PM

Edited by: Swarup Sawant on Mar 18, 2008 1:51 PM

Edited by: Swarup Sawant on Mar 18, 2008 1:54 PM