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

Prerequisites: json.jar

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

def generatePrgrmDocReport() {
        
        JSONObject json = new JSONObject();
        json.put("fileType", "PDF");
        json.put("useAlias", false);
        json.put("stringDelimter", "_");
        
        String povGroupMember = "2016_January_Actual";
        
        def url;
        def response;
        
        String urlString = serverUrl + "/epm/rest/"+ apiVersion + "/applications/" + appName + "/povs/" + povGroupMember.trim().replaceAll(" ", "%20") + "/programDocumentationReport";
        urlString = urlString + "?" + "queryParameter=" + json.toString();
        
        try {
            url = new URL(urlString);
	} catch (MalformedURLException e) {
            println "Malformed URL. Please pass valid URL"
            System.exit(0);
	}    
        
        response = executeRequest(url, "GET", null, "application/json");
        JSONObject jsonObj = new JSONObject(response);
        int resStatus = jsonObj.getInt("status");
        
        if(resStatus == 0) {
            println "Program Documentation Report Generated Successfully"
        }
        String details = jsonObj.getString("details");
        println details
            
    }