Occasionally there is something that comes up where if only you could do 'X' then Essbase/Planning would be able to solve a problem you have.
In order to add functionality to essbase a common approach would be to create a Custom Defined Function (CDF) using Java. One of the interesting things about Groovy is that at the end of the day you can compile it to a jar as if it were java and you just need to distribute your jar along with the Groovy All jar.
To showcase creating a CDF with groovy we will attempt to create an extremly simple example.
Our exercise will be to create a CDF that doubles a number. Hardly a task that merits a CDF or Groovy but it's a simple example just to open the door and show that it is possible and here is now to do it.
I'd like to start that most of this information is available on the essbase DBAG and you'll end up refering to that at some point if you take this upon yourself. Also I can't remember where on the net I picked up some of the knowledge but there are great webpages out there and if I remember which ones I learned this from I'll add the credits.
To start you'll need to create a folder structure.
I used the following:
You'll also need to define a few variables:
And add both to the path
The groovy code is extremely simple.
Once you've got the groovy typed out you can run the following compile.bat file to compile the script to a jar file.
Next we'll copy the jar files groovy-all-2.4.6.jar and HypFunctions.jar to the essbase application folder:
PS F:\Oracle\Middleware\user_projects\epmsystem1\EssbaseServer\essbaseserver1\app\DEMO1> dir
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/14/2016 2:58 PM Plan1
-a---- 9/14/2016 3:22 PM 189 DEMO1.apb
-a---- 9/14/2016 3:22 PM 189 DEMO1.app
-a---- 9/14/2016 3:22 PM 7404 essfunc.xml
-a---- 5/23/2016 10:59 AM 7024433 groovy-all-2.4.6.jar
-a---- 9/14/2016 2:23 PM 11129 HspCDFUt.cdf.jar
-a---- 9/14/2016 3:08 PM 2429 HypFunctions.jar
Note the two new Jars.
Once that's done we'll need to register the function.
We can run the MaxL Shell Script:
We'll need to restart essbase at this point (Or at least the application.)
You'll want to look out for this entry in the application logs to confirm the CDF loaded successfully:
External [LOCAL] function [@JMultiplyNumberByTwo] registered OK
Once we see that, we're in good hands.
We'll now move onto Calc Manager (or EAS) to get a script working.
This is the script I elected to put together for this example:
Once thats saved and deployed you can attach it to a form as a run on save
Hopefully at this point you can now test the form and everything is working.
Hope this helps, if anyone wants to see something more complex done drop some suggestions below and i'll see what we can do to make it happen.