cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a UDF

Former Member
0 Kudos

How to create a UDF if I have to check after comparing two values and then checking if MATNR is greater 90000000000 and less than 9999999999 and only then I can pass the value of the field MATNR.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Below code works perfect for me. I hope this will help you.

Declare Imports under Inport section: java.util.*; java.math.BigInteger;

BigInteger bi1 = new BigInteger(MATNR);
BigInteger bi2 = new BigInteger("90000000000");
BigInteger bi3 = new BigInteger("99999999999");

if (bi1.compareTo(bi2 )== 1 && bi1.compareTo(bi3 )== -1)
{
return MATNR;
}
return "";

Try this and let me know.

Regards,

Sarvesh

Answers (3)

Answers (3)

GabrielSagaya
Active Contributor
0 Kudos

imports= java.maths.BigDecimal;

function myudf(String a, Container container)

{

BigDecimal big = new BigDecimal(a);

if (big < 9999999999 and big > greater 90000000000)

return big.toString;

else

return "";

}

/people/thorsten.nordholmsbirk/blog/2006/04/03/never-ever-use-xis-built-in-arithmetic-functions

Former Member
0 Kudos

Hi,

> How to create a UDF if I have to check after comparing two values and then checking if MATNR is greater 90000000000 and >less than 9999999999 and only then I can pass the value of the field MATNR

Create simple UDF and use the long data type instead of int.

if (matnr < 90000000000 && matnr > 9999999999)

return matnr;

Regards

Ramesh

Former Member
0 Kudos

Hi,

Pass the two values to be compared and also MATNR no also...

in udf

MATNR1 = Integer.parseInt(MATNR);

if(value1.equals(value2))

{

if(MATNR1 > 9000 ... &if MATNR <9999//)

return MATNR

by using like above u can start proceeding...

note : i have just given the idea of start need to modify according to your requirement...

HTH

Rajesh