In part 1 we have established a concrete case for the Approval of Leave Request from Fiori and ESS/MSS Synchronously. We also established one business scenario and a practical one. We also discussed that there are numerous discussions posted in SCN and are still unanswered.
In this part we will discuss and develop a solution to cater almost all Leave Request Approval problems regarding the Workflow. So here we go with the Solution.
- Customized SAP Standard Leave Request Workflow (single level) to Multi-Level and according to the customer requirement
- Make the workflow synchronous for ESS/MSS and SAP Fiori. This means that the Approval task would be one and should work for both technologies.
Steps to handle Challenges
Customize the Workflow to Multi-Level
I am quite sure that most of have done that with ease despite of the issues you faced but I feel like putting this up because this is important. Below you see is the snapshot of the workflow customized to make it up and running for Multi-Level Approvals. I have changed the workflow logic altogether and it’s working.
First of all, Request ID and initial approval is set just before the approval process is started. Then, the approval process starts.
Here, I am starting the approval process and checking if Request status is Approved or Withdrawn or Rejected. If REJECTED or WITHDRAWN complete the workflow. If APPROVED check if there is a next approver or not.
Above snapshot is simple but a bit tricky, I am checking next approver is there or not? If there is no agent why I am setting status to APPROVED and if there is next agent why am I setting the status to SENT? Confusing! Yup, this is confusing but I can clear this right away.
- If there is next agent, then the request status should be changed to SENT else it won’t go to next approver. Another reason for setting the request status to SENT is that, in table PTREQ_HEADER latest row for the request ID is APPROVED so this has to be changes to SENT in order to loop the workflow to next agent
Now, the tricky part! Sometimes I don’t know how but this happens, the request status is not set to APPROVED somehow. So, in order to cater, I am checking if there is no agent, then the status should be changed to APPROVED and workflow should get completed by failing the loop condition. I hope this clears everything up.
Above screenshot is very easy, I am getting the current status of the Request, is it SENT (means there are other approvers as well), is it APPROVED (means no other approver). In Loop I have put the following condition: &EV_NEW_STATUS& ≠ SENT. In case of next approver loop condition would get true and loop with work else it won’t and will go to next step.
Above part is standard, I have just made one change if there Leave Request is REJECTED or WITHDRAWN send an email and SMS.
Rest of that is standard, wait for status change. Only change is, when a leave request is posted in the system, send an Email and SMS.