11/25/09

Java Customized Calc Function

The essbase already have many functions for calculation. We can create customized calculation functions by Java. Steps:
1. Create a Java function,CalcFunc.java
public class CalcFunc {
public static double sum (double[] data) {
int i, n = data.length;
double sum = 0.0d;
for (i=0; i< n ; i++)
{
double d = data [i];
sum = sum + d;
}
return sum;
}
}
2. compile,run with javac CalcFunc.java, and generate CalcFunc.class
javac CalcFunc.java
C:\app\bob\product\11.1.0\db_1\jdk\bin\javac.exe C:\Hyperion\CustJava\CalcFunc.java
3. Put the class file in the jar file
jar cf jar_filename class_filename
jar cf CalcFunc.jar CalcFunc.class
4.On the computer running Essbase Server, copy the .jar file to one of the following directories (if the directory does not exist, create it):
For .jar files containing global custom-defined functions:
ARBORPATH/java/udf/
C:\Hyperion\products\Essbase\EssbaseServer\java\udf
For .jar files to be used only with specific applications:
ARBORPATH/app/AppName/udf/
5. Register
create function Sample.'@JSUM'
as 'CalcFunc.sum'
spec '@JSUM(memberRange)'
comment 'adds list of input members';