Groovy Sample – RunCalculation.groovy for Oracle Profitability and Cost Management Cloud

Prerequisites: json.jar

Common functions: See Appendix C: Common Helper Functions for Groovy.

def runCalculation() {
        
        String subsetStart = null;
        String subsetEnd = null;
        String ruleName = null;
        String ruleSetName = null;
        
        JSONObject json = new JSONObject();
        json.put("isClearCalculated", true);
        json.put("isExecuteCalculations", true);
        json.put("isRunNow", true);        
        json.put("comment", "Run Calculation");
        json.put("subsetStart", subsetStart);
        json.put("subsetEnd", subsetEnd);        
        json.put("ruleName", ruleName);
        json.put("ruleSetName", ruleSetName);
        json.put("exeType", "ALL_RULES");
        json.put("stringDelimiter", "_");
        
        String povGroupMember = "2014_January_Actual";        
        String urlString = serverUrl + "/epm/rest/"+ apiVersion + "/applications/" + appName + "/povs/" 
                                       + povGroupMember.trim().replaceAll(" ", "%20") + "/jobs/runLedgerCalculationJob";
                
        def url;
        
        try {
                url = new URL(urlString)
        } catch (MalformedURLException e) {
                println "Malformed URL. Please pass valid URL"
                System.exit(0);
        }        
        executeJob(url, "POST", json.toString());        
    }