Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
RubaElhafiz
Participant
Introduction:

Managing and controlling overtime requests efficiently is crucial for any organization to ensure appropriate resource allocation and maintain budgetary discipline. This blog post will explore how SAP Cloud Platform Integration (CPI) can be leveraged to automate and streamline the overtime approval process in SAP SuccessFactors. We will focus on integrating SAP CPI with SuccessFactors to automatically approve or reject overtime requests based on the availability of the budget.

 

** Kindly note that this blog specifically describes how to customize the iflow, and it uses customized SuccessFactors APIs

 

Approach:

Using SAP SuccessFactors, we will create a user that will be used by CPI and serve as the second approver to the overtime request workflow. We will concentrate on establishing a CPI user as the second approver to evaluate budget availability before accepting or rejecting overtime requests. Before we get into the technical details, let's go over the redesigned overtime approval protocol in SuccessFactors:

  • An employee submits an overtime request through the SuccessFactors user interface.

  • The request is initially routed to the employee's immediate supervisor or manager (first approver).

  • After the first approver reviews the request, it is forwarded to a CPI user designated as the second approver.

  • The CPI user performs budgetary control to determine the availability of the budget for the requested overtime.

  • Based on the budget availability, the CPI user decides whether to approve or reject the request.

  • The decision is communicated back to the employee, and if approved, the overtime is processed accordingly.


 

SuccessFactors side:

  • Create a user for CPI

  • Give the user all the needed permission

  • Make sure that your Admin Center > Object definitions of your custom entity (e.g., cust_Overtimepreapprovalparent) is set with "Pending Data" equals to "Yes". Check: https://me.sap.com/notes/0002604638


 

CPI side:

Step (1): Insert the CPI’s user credentials:

Go to monitor > Security Material


Create > User Credentials


Fill up the fields using the credentials specification that was produced in SuccessFactors and choose the type: SuccessFactors. For example:


Deploy and create a new user but this time the type should be User Credentials, and the user should be put as user@companyid as shown in the following photo:


Deploy

Step (2):  Build the iflow

Start the iflow by adding a Timer to trigger the iflow


As per the business request, the Timer will be set to recur every 30 sec


Then, the Timer will be connected to the Request-Reply, and the Request Reply and a “Receiver will be connected using a SuccessFactors adapter


Choose the Message Protocol to be OData V2


Configure the adapter:

Connection: Choose the address depending on the data center and the environment by pressing the select button.



Then enter the Credential Name field using the previously established SuccessFactors type one.


Processing:

Operation Details: Get

Resource Path: Select


This step depends on the name of the overtime approve request API in the SuccessFactors, in our case the API name is: cust_Overtimepreapprovalparent, in this API there are the following fields:

  • cust_overtimeamount: it displays the cost of the requested overtime

  • externalCode: contains the ID of the employee that requested the overtime


From the wfRequestNav, the following field will be fetched:

  • currentStepNum: indicates the number of the current step in the workflow

  • externalCode: unique number for each request

  • wfRequestId: the id of the workflow of the overtime request



** Fill in the Custom Query Options as recordStatus=pending

Choose the Pagination to be Client


Add General splitter


Configure the splitter as per the received XML, to process each request individually


Add Content Modifier


Add the currentStepNum, wfRequestId, overtimeAmount, and the externalCode of the cust_Overtimepreapprovalparent in the Property as shown:


Add Router to examine if the first approver (e.g., manager or supervisor) has approved the request, by checking the currentStepNum if it is equal to ‘2’

${property.currentStepNum} = '2'



Connect the Default Route to the End Message, and the other route should be connected to the Request Reply, and the Request Reply will be connected to a new Receiver


Configure the adapter between the Request Reply to be SuccessFactors, Message Protocol to be OData V2

In this connection we need to figure out the department that this employee belongs to, so we can get the department budget letter on, the used API in our example is “EmpEmployment”, and we will filter on the userId using the property named externalCode


Add Content Modifier to save the Department as Property



Add Request Reply and Receiver to get the Budget of the Department, use the adapter typed SuccessFactors, Message Protocol to be OData V2


The used API that contains the budget of the employee’s department in our example is “cust_budgetcheck”, and we will filter on the “cust_department” using the property named department


Make sure that while fetching the data you choose Generate XML Schema Definition, to be used in the Message Mapping


Add Message Mapping


Create the mapping by making the generated XML Schema as the Target and Source file


The following mapping in this example is:

  • externalCode connected directly to externalCode

  • cust_Consumedbalance in the target, which contains the consumed balance, will be connected to the Property cust_overtimeamount



*** To get the readPropertyValue mapping expression: https://help.sap.com/docs/cloud-integration/sap-cloud-integration/access-header-and-properties-in-me...

  • cust_budgetbalance connected directly to cust_budgetbalance (it contains the budget before making any deduction)

  • cust_remainingbalance: it contains the cust_budgetbalance minus the cust_Consumedbalance minus the overtime amount



Make sure to add the fixValues to the cust_budgetbalance and cust_Consumedbalance, so if they don’t have any value, it will be assumed that they contain the value ‘0’




  • effectiveStartDate in the target should include the date of the last modification, therefore it will be connected to the currentDate



Add Content Modifier, and add the remainingBalance in the Property as shown



Add Router to examine if there is enough budget to approve the overtime request, by checking the remainingBalance if it is equal to or greater than ‘0’

${property.remainingBalance} >= '0'





  • If there is no budget the Router will be connected as follows (Default Route):


Content Modifier > Request Reply > Receiver > End Message

The Content Modifier Header: Content-Type: application/xml


The Content Modifier Body:

<d:WfRequestActionResponse>

<d:element m:type="SFOData.WfRequestActionResponse">

<d:status>success</d:status>

<d:wfRequestId m:type="Edm.Int64">${property.wfRequestId}L</d:wfRequestId>

</d:element>

</d:WfRequestActionResponse>


Request Reply connected to Receiver through HTTP adapter


Address: https://<api-server>/odata/v2/rejectWfRequest

Query: wfRequestId=${property.wfRequestId}L

Method: Post

Credential Name: use the previously established User Credentials type one





  • If there is a budget the request should be approved and the budget should be updated, accordingly the Router will be connected to Sequential Multicast:

  • The first path will be: Content Modifier > Request Reply > Receiver > End Message


This path will be to approve the overtime request

The Content Modifier Header: Content-Type: application/xml

The Content Modifier Body:

<d:WfRequestActionResponse>

<d:element m:type="SFOData.WfRequestActionResponse">

<d:status>success</d:status>

<d:wfRequestId m:type="Edm.Int64">${property.wfRequestId}L</d:wfRequestId>

</d:element>

</d:WfRequestActionResponse>



Request Reply connected to Receiver through HTTP adapter


Address: https://<api-server>/odata/v2/approveWfRequest

Query: wfRequestId=${property.wfRequestId}L

Method: Post

Credential Name: use the previously established User Credentials type one





  • The second path will be: Request Reply > Receiver > End Message


This path will be to update the budget

The adapter type is SuccessFactors, Message Protocol to be OData V2

Method: Post



 

Conclusion:

By incorporating a CPI user as the second approver in the overtime approval workflow in SuccessFactors, organizations can automate budget control and improve control over resource allocation. SAP CPI's integration capabilities, combined with the budgetary control logic implemented by the CPI user, provide an efficient solution for managing overtime requests. This approach enhances operational efficiency, reduces costs, and ensures accurate budget control. However, it's important to customize and adapt this solution to fit your organization's specific requirements and workflow processes.

 

References:

 
6 Comments
Labels in this area