cancel
Showing results for 
Search instead for 
Did you mean: 

Need to display Error message when there are no approvers found in leave workflow

Former Member
0 Kudos

Dear experts,

In a customized leave workflow for HCM ( Time Module ), we are facing an issue. As per requirements, when there are no approvers found for an user's request then on the portal, it should display an error message. This is a one level cusomized workflow. If requester's approver is blank then it looks for its 1 level up approver and if one level up approver is also not available then it should throw an error message. I was understanding that standard BADI PT_GEN_REQ throws this message automatically when there are no approvers found. I was wrong. Even though there are no approvers, on portal, message is displayed as 'Leave Request was sent successfully.' in workflow logs, there are no approvers found as expected. Functionality wise it is correct ( approvers are coming blank in the logs ) but I want to display error message. That is not coming. I have also observed one more issue. Even though as per logs, there are no approvers, it shows that 'All users can process this task'. This might be coming because, workflow doesn't find any approvers so all the users who have rights to approver might be able to approve. Would you please advise./guide me how to bring the error message ? As per my little understanding, if I succeed to display error message, then work item can not go to any users' UWL. Please correct me if I am wrong. Thank you.

Best regards.

Abhijit.

Message was edited by: Abhijit Kamatkar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I think this is not actually a pure workflow problem. The leave request application is responsible for finding the agent or making the user to enter it (at least in the standard solution), and the workflow just uses that agent.

Have you checked the workflow settings for the leave types in IMG -> ESS -> Service Specific Settings -> Working time -> Leave request -> Processing processes? I think there is some kind of option for forcing to have something in the next processor (approver) field? I am not sure about this, but the field "Not necessary to enter next agent" might work. I mean that if this is empty, then the application might let you to sent the leave request with no approver.

Other option might be that you add your own code to the BADI to do some additional checks when submitting the leave. Submit an error message if the next processor field is empty. I am not sure, if this is possible, but worth to check.

Kind regards,

Karri

Former Member
0 Kudos

Hi Karri,

Indeed thank you for replying. I checked the configuration in SPRO with functional associate. It looks fine to us.

I chose the second option to enhance the BADI. I was thinking to implement BADI PT_GEN_REQ ( This BADI gets trigger at the time of generating request. I was looking for this badi because it has methods : CHECK_IF_ACTOR_ABSENT, SEARCH_FOR_NEXT_PROCESSOR, FIND_RESP_AND_DEFAULT_NEXT_PRC ( commented code in standard method etc )  ) and PT_ABS_REQ (This badi gets triggered at the time raising request using particular leave type. This BADI is used for validation for leave request to control leave processing. Validations for ESS Leave request - ERP Human Capital Management - SCN Wiki . It has methods like AUTH_CHECK_AND_ANONYMIZE_DATA and GET_WORKFLOW_ATTRIBS). Therefore, i wanted to check whether these BADI trigger or not. So, using CL_EXITHANDLER, I tried to debug.those badi. PT_ABS_REQ got triggered. Even though from workflow side, there were no approvers fetched, but because task is generalized, all users are able to process the task, in the next processor it showed every possible user who would be able to approve the work item. I am confused about this now. How would I pop up a error or warning message when there are no approvers in the org unit ?

Kindly provide your inputs.

Best regards.

Abhijit

Former Member
0 Kudos

Experts,

Please suggest your ideas. I think implementing badi PT_ABS_REQ might work. My concern is, it should not show all the approvers in deep structure, IM_ATTABS_TAB. Let me try with this approach. Any ideas or suggestions are welcome. Thank you.

Best regards

Abhijit

Former Member
0 Kudos

Hi,

I cannot remember the details, but basically you should be able to "validate" the leave request data with some of the methods of the BADI (actually isn't there two BADIs?). By validate I mean that you can make additional checks for the data entered in the leave request, and if there is something wrong, you can display an error message. Now I am not absolutely sure about this, but there might be a field NEXT_PROCESSOR (or agent or something like that) in some of the parameters of the method. Now you could perhaps check if that field is initial, and if it is, then just give an error. I am not sure if it will work like this, but this is what I would check first, and how I would most probably try to solve the problem.

You the BADI doesn't work, then you can of course always try to find some nice spot in the standard code for a small enhancement. If you are using the "new" leave request applications made with WDA, you have even more possibilities. Of course this will require some above-beginner-level skills.

As a general comment I would say that me as a user would be very frustrated to get an error message when submitting a leave request. I would hope to be still able to submit the leave request and then someone responsible for maintaining the organisation would get notified automatically.

Regards,

Karri

Former Member
0 Kudos

Hi Karri and experts,

Thank you for your reply.

Well, I managed to resolve this issue and it was worth to check both BADIs in order to resolve this issue. I could say that both BADIs can be used to display the error message.

1)PT_ABS_REQ - Class CL_PT_ARQ_REQ_EXIT and in the method : IF_EX_PT_ABS_REQ~SIMULATE_VIA_BLOP. In table im_attabs we get details of the initiator (( pernr ) who has applied for the leave. Then using pernr details, I was able to find his approver and approver's manager. If both of them are empty, I throw an error message using message handler. This worked for me.

2)PT_GEN_REQ - Class CL_DEF_IM_PT_GEN_REQ and in the method : IF_EX_PT_GEN_REQ~START_WF.

In this standard method itself, we get work item details. Once you get work item, you also get contents of the workflow container. Then it was easier to see whether approver is present or not. If he is not present, I display an error message on the portal using message handler.

I preferred PT_ABS_REQ as I don't need work item details. Initiator's details are more than sufficient in my case.

Thank you very much for your suggestions and inputs.

Resolved.

Answers (2)

Answers (2)

Former Member
0 Kudos

>Even though as per logs, there are no approvers, it shows that 'All users can process this task'. This might be coming because, workflow doesn't find any approvers so all the users who have rights to approver might be able to approve.

Yes, this is correct. Most probably the task has been set as "General task", which means that all users are the possible agents for the users (=there is no restrictions for who can process leave approvals). This is not an error.

Kind regards,

Karri

Former Member
0 Kudos

Hi,

Can you tell how you are going to determine the agent? Which workflow you are  using for this, standard or custom?

Regards,

Murali Krishna.

Former Member
0 Kudos

Hi Murali,

Thank you for replying.

As mentioned, I am using custom workflow. To determine agent, I am fetching agents from tables based on relationship and for actual approval process standard task TS21500003 is being used which is a general task. My problem is not to determine correct agent. My problem is when there is no agent in my org. structure, I want to display an error message. I also know that because my task is generalized, this work item can be processed by all users at the moment. Once I know, how to bring the error message, the workflow would not allow to create such wrong request. I want to know that mechanism. Thank you.

Best regards.

Abhijit.

Former Member
0 Kudos

What do you mean by Relation ship?

By the end of the day, you need to pass the agent values to a RULE or to an element of a task. How you are doing this?

Former Member
0 Kudos

It is not mandatory to use RULE to determine the agents. Agents can be determined using class/expressions as well. At the moment, my problem is not about how to fetch the agents. I am referring to display an error message or warning message when there are no more agents who can approve the work item. Let me elaborate this. At the moment, workflow works fine when the agents are determined. Consider below example.

A raises a request and it goes to B. B approves it. Workflow ends here. No issue in this scenario.
Now, A raises a request, it should go to B but B is not available so it goes approver C who is B's approver as per hierarchy. Now, C is also not available and C is last available agent/approver. Hierarchy ends here.In this scenario, I want to display a message like say "Approver does not exist. Consult your HR". In workflow logs, approvers are not present as expected which is correct. I am expecting that after displaying this error message, user should understand that this may not be a valid request.

I hope, I have written clearly here. I am not facing issue in agent determination here.

Experts, kindly suggest your inputs. Thank you.

Best regards.

Abhijit.