Create Function

The MaxL create function statement helps you create and register your custom-defined Essbase calculation function (CDF), using a Java method.

Minimum permission required:

  • Application Manager to create a local (application-level) function.

  • Administrator to create a global (system-level) function.

The general workflow for creating your own custom-defined functions in Essbase is as follows:

  1. Develop the functions in Java classes.

  2. Use the create function MaxL statement to register your functions in the Essbase calculator framework.

  3. You can now use the functions in the same way that you use the standard Essbase calculation functions.

For full information, refer to Developing Custom-Defined Calculation Functions.

Syntax


Description of crefunc.gif follows
Description of the illustration crefunc.gif

Use the MaxL create function statement to create a function in the following ways:

Keywords

create function FUNC-NAME as JAVACLASS.METHOD

Register with Essbase a custom-defined function developed in Java, either as a global function usable by the entire Essbase Server, or as a local function available to an application. To register a global (server-wide) function, use one token for FUNC-NAME. To register a local (application-wide) function, use two tokens for FUNC-NAME.

create or replace function FUNC-NAME as JAVACLASS.METHOD

Register with Essbase a global or local custom-defined function. If a function with that name already exists in the custom-defined function and macro catalog, it is replaced.

create or replace function ... spec

Enter, for the custom-defined function, an optional Essbase calculator-syntax specification string, such as in the following example: @COVARIANCE (expList1, expList2). Use a specification string if you wish the function to be returned by the output string of the IEssCube.getCalcFunctions Java method or EssListCalcFunctions C API function.

Note:

If you do not specify a calculation specification string, you cannot specify a comment either.

create or replace function ... with property runtime

The optional with property runtime clause designates the custom-defined function as a runtime function. Normally, Essbase pre-executes CDFs whose arguments are available at compilation time. The Runtime property prevents that optimization, executing functions that have constant values as operands (or no operands at all) for every block in the function range. If the built-in @CALCMODE(CELL) function is used, a CDF declared as Runtime can execute on every cell in the range.

Note:

No built-in Essbase calculator functions have the Runtime property.

The Runtime property should be applied only in special circumstances, as it can seriously affect performance. The runtime property might be desirable for any CDF whose return value depends on something besides its arguments; for example, the current date, or values in a rapidly changing relational table. If you created a runtime function @RANDOM() that returns a new random number each time it executes, then a member formula such as "Mem1 = @RANDOM();" would return different values for each block. At compilation time, the Runtime property prevents the pre-execution of CDFs that are applied to constants.

create or replace function ... spec CALC-SPEC-STRING comment

The optional comment clause enables you to include a description of the custom-defined function. You cannot create a comment without also using spec to create a calculator-syntax specification string. The optional calculator-syntax specification string and the comment are used as the output string of the IEssCube.getCalcFunctions Java method or EssListCalcFunctions C API function.

Notes

  • To create a global or system-level function, use a single name for FUNC-NAME. For example, '@COVARIANCE'.

  • To create a local or application-level function, use MaxL's double naming convention for FUNC-NAME. For example, Sample.'@COVARIANCE'. The second token must be enclosed in single quotation marks because it contains a special character.

Example

The following example registers a global CDF named @COVARIANCE. The code for this sample function is available on the Essbase Server, in <Oracle Home>/essbase/products/Essbase/EssbaseServer/java/essbase.jar.

create function '@COVARIANCE' as 'com.hyperion.essbase.calculator.Statistics.covariance' spec '@COVARIANCE (expList1, expList2)' comment 'computes covariance of two sequences given as expression lists';