Human Capital Management Blogs by SAP
Get insider info on HCM solutions for core HR and payroll, time and attendance, talent management, employee experience management, and more in this SAP blog.
cancel
Showing results for 
Search instead for 
Did you mean: 
Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
SAP Commissions Rest API allows 2 types of authentication i.e. Basic Authentication and JWT Token Authentication. Customer can choose any one type of authentication to make api calls from SAP Advanced workflow. This blog post will explain a sample of groovy script in SAP Advanced workflow to make api calls to SAP Commissions using basic authentication.

1) Create custom parameters in advanced workflow to Store commissions api endpoint url and credentials

Path: Set Up → DEVELOPMENT → Custom Parameters → Add New































Name Description Type Category Value
comm.api.uri  API End Point Text Commission https://<tenatid>.
callidusondemand.com/api/v2
comm.api.user User with Proper Authorization Text Commission <User Id>
comm.api.password Password Password Commission <Password>

2) Write a workflow Groovy script of 'Util' Type to make api calls to Commissions

Path: Set Up → DEVELOPMENT → Scripts → Add New


code:
def fnPrepareCommHeaders(){

def oHeaders = new java.util.HashMap();
oHeaders.put('content-type','application/json');
oHeaders.put('Accept', 'application/json');

def sUser = resp.getAppParam("comm.api.user");
def sPassword = resp.getAppParam("comm.api.password");
def sCredentials = sUser + ":" + sPassword ;
def b64Credentials = sCredentials.bytes.encodeBase64().toString();
def sAuthorizationHeader = "Basic " + b64Credentials;
oHeaders.put('Authorization', sAuthorizationHeader);

return oHeaders;
}

def fnCallCommissionsAPI(sMethod, sUrl, sBody){

def oResponse;
def oHttpClient = resp.createHttpClient();
def oHeaders = fnPrepareCommHeaders();
String sURL = resp.getAppParam("comm.api.uri") + sUrl;

switch(sMethod){
case 'GET':
oResponse = oHttpClient.executeHttpGet(sURL, oHeaders);
break;
case 'POST':
oResponse = oHttpClient.executeHttpPost(sURL, 'application/json', oHeaders, sBody);
break;
case 'PUT':
oResponse = oHttpClient.executeHttpPut(sURL, 'application/json', oHeaders, sBody);
break;
case 'DELETE':
oResponse = oHttpClient.executeHttpDelete(sURL, oHeaders);
break;
default:
break;
}
return oResponse;

}

 

3) Call above util function from any required script to Get/Create/Update/Delete any commissions resources.

Sample code to get Period Information from Commissions:
import groovy.json.JsonSlurper;
def utilCommApi = resp.importScript("commissions_functions");

def sResponse = utilCommApi.invoke("fnCallCommissionsAPI", 'GET', '/periods','')

def jsonSlurper = new JsonSlurper()
def jsonResponse = jsonSlurper.parseText(sResponse.getContent());
logger.info("Periods-:", jsonResponse);

 

Conclusion - SAP Commissions can be integrated with Advacned workflow by calling Rest APIs using basic authentication.

You can also find additional information on following links:

Please feel free to provide any feedback you have in the comments section below and ask your questions about the topic in sap community using this link.
2 Comments