cancel
Showing results for 
Search instead for 
Did you mean: 

standard XI function inside udf

Former Member
0 Kudos

The requirement is like i want to take 5 digits after decimal point. But I have to do this as part of udf.

Here I am trying to use standard XI function inside udf.

Here is my code:

com.sap.aii.mappingtool.flib3.Arithm;

double conv1=0.0;

double Input=0.123456789;

Arithm ar = new Arithm()

conv1=ar.FormatNum();

Where I have to mention the property(like 0.00000) here?

Accepted Solutions (0)

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos

You have to set parameters in the container:

Arithm ar = new Arithm();
String input = "1.23456789";
container.setParameter("nformat","0.00000");
container.setParameter("separator",".");
String output = ar.formatNumber(input,container);

Note that all functions of the graphical mapping tool work on String.

The formatNumber uses the standard class java.text.DecimalFormat.

You might use that class directly.

Regards

Stefan

Former Member
0 Kudos

Don't really understand about standard XI function inside udf

Anyway UDF is a piece of java code. You can use any java classes.

for your requirement, why not just convert the number into string and take the first 5 characters after the char '.' and then convert the result string into number?

Jayson

Former Member
0 Kudos

Hi,

in this case they have to be set in the container parameters.

It's explained here:

/people/venkataramanan.parameswaran/blog/2007/02/06/is-there-a-possibility-to-access-xi-standard-functions-in-user-defined-functions-yes

Regards

Patrick

Edited by: Patrick Koehnen on Jan 7, 2009 3:55 PM