Monday, April 11, 2022

Groovy and Essbase Cloud APIs - Part 2

 In my previous blog, I showed you how to install Groovy on Linux using SDKMAN.

The second step is to create a working directory to put all of Essbase API files and groovy scripts in one place. By default, you need oracle user to access the API files, so I’m going to copy them into a directory under opc user which I’m going to use to run my Groovy scripts.

The API files are located under /u01/oracle/essbase/common/EssbaseJavaAPI/*

I’m going to need three jar files

1.      ess_japi.jar

2.      ess_es_server,jar

3.      ojdl.jar

To copy the files, I will run the following commands:

sudo cp /u01/oracle/essbase/common/EssbaseJavaAPI/lib/ess_japi.jar /home/opc/EssbaseJAPI/ess_japi.jar

sudo cp  /u01/oracle/essbase/common/EssbaseJavaAPI/lib/ess_es_server.jar /home/opc/EssbaseJAPI/ess_es_server.jar

sudo cp  /u01/oracle/essbase/common/Essbase/jlib/ojdl.jar  /home/opc/EssbaseJAPI/ojdl.jar

 The next step is to define CLASSPATH variable.

export CLASSPATH=”/home/opc/EssbaseJAPI/ess_japi.jar: /home/opc/EssbaseJAPI/ess_es_server.jar: /home/opc/EssbaseJAPI/ojdl.jar”


 Create a Groovy Script

The final step is to create the Groovy script, run the script and test it but first I need a use case.

I want to search the Sample application outline for members based on alias descriptions, not member names. The standard outline search feature available via the simplified interface is not going to do the job for me as shown next:






So, I’m going to write a simple Groovy script to search the outline based on member aliases. Here is the code:

I've intentionally used "def" to define untyped variables just to highlight the Groovy nature of the code, I personally like to declare the data type for better readability. For example, instead of "def cube" I would type "IEssCube cube



In my next post, I will explain the code and show you how to run it.


Thanks

No comments:

Post a Comment