Dayalan Punniyamoorthy Blog

Thursday, April 18, 2024

Groovy Rules Calling Enterprise Profitability and Cost Management Rules using REST API!


Using the Groovy script we can invoke the following REST API provided by an Enterprise Profitability and Cost Management system.

  • Calculate Model - Runs the calculation on a given point of view in a selected cube.
  • Clear Data By Point of View - Clears the data for a given point of view in a selected cube.
  • Copy Data by Point of View - Copies data from a source to a destination point of view in a selected cube.
  • Delete Point of View - Deletes the data associated with a point of view from the calculation cube.
  • Generate Model Documentation Report - Generates an Enterprise Profitability and Cost Management Model Documentation report. Any validation failures are written to file with file name provided in the parameters and can be accessed from Inbox/Outbox Explorer.
  • Validate Model - Automates the calculation process for validating a model. Any validation failures are written to file with file name provided in the parameters and can be accessed from Inbox/Outbox Explorer.
  • All this are asynchronous call, so use the job status URI to determine whether the operation is complete. For running all the above REST API Required Roles is Service Administrators.

 URL Structure for Enterprise Profitability and Cost Management

https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/HyperionPlanning/rest/v3/{path)

 path—Identifies the resource

In this blog we will be discussing on how to run the Calculate Model that runs the calculation on a given point of view in a selected cube. 

Using the POST method the REST Resource /HyperionPlanning/rest/v3/applications/{AppName}/jobs/ is called 

Watch a demo on Creating Models and Rules in Enterprise Profitability and Cost Management 

Under Modeling  


Click on Calculation Control 




Under that you can select the POV to run the calculation for and hit Calculate Model 


It will give further selection box to select other options. You can choose the various other options like 
    Clear Calculated Data 
    Capture Diagnostic Data etc.. 


Under Processing Range you have, 

We will see the demo for Ruleset Range,
 The job is triggered 


And the details of the Job is below,

Now we will be triggering the same rule via Groovy by using the Job details, 
The documentation can be found here  


And the sample payload is taken from the document, If you notice it does resembles the Job details.





Calling the EPBCM REST API from Groovy rule, So this rule will invoke EPCM Calculation using the REST API to call the Calculate Model. 

Following are the mandatory parameters that needs to be passed to the REST API to invoke the model 



And we are specifying the parameters in the Groovy rule.


jsonResponse = operation.application.getConnection("Localhost").post('/rest/v3/applications/AppName/jobs/')
    .header("Content-Type", "application/json")
    .body(json([
    "jobType":"Calculation",
    "jobName":"Run Calculation for Range - 50",
    "parameters":[
        "povDelimiter":":",
        "povName":"FY24:Dec:Actual:Working",,
        "modelName":"XXX- Calcs",
        "executionType":"RULESET_SUBSET",
        "rulesetSeqNumStart":"50",
        "rulesetSeqNumEnd":"50",
        "clearCalculatedData":"true",
        "executeCalculations":"true",
        "optimizeForReporting":"true",
        "captureDebugScripts":"false"]
        ])
    )
    .asString();
  println 'Response Received'
  println jsonResponse.body

If you notice we are getting the Server URL using the Connection, I have already defined a Connection by the name Localhost and using that connection. 

This is the Output under the Jobs console, 

Hope this helps, Happy days on the Cloud!!!



No comments:

Post a Comment