Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 31, 2014 at 04:24 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • Dec 30, 2014 at 02:22 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Murali Krishna

      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.

  • avatar image
    Former Member
    Dec 31, 2014 at 04:13 AM

    >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

    Add comment
    10|10000 characters needed characters exceeded