cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with two level ESS leave request workflow

Former Member
0 Kudos

Dear Friends,

We have copied the standard leave request workflow WS12300111 and enhanced it with two levels of approval.

As per the Workflow design of the leave Approval, the Status of the leave request will be in SENT Status when the employee sends the leave request for approval. When the Manager approves the leave request the status of the leave request will be changed to APPROVED. The workflow system will then change this again to SENT for second level approval(this is not available in standard) and when the second level approver approves the leave request the status is again changed to APPROVED(part of standard). The background job which posts the leave requests RPTARQPOST will pick the all leave request which has a status APPROVED and create a leave request in R/3 and finally change the status as POSTED. For changing the leave request status from APPROVED to SENT(intermediate step) we have created a method inside the class CL_PT_REQ_WF_ATTRIBS and call that method inside a task in workflow and we are using the following code to change the status. The issue we are facing is the leave request are getting posted without the second level approval, means the worklfow is in ready status(for second level approval) but the leave request is having the status as "Posted", and because of this when the second level approver opens his work item from UWL, he cannot see those leave request. Please advice what could be the issue and how to trouble shoot this problem. I tried to simulate the same issue in Quality system and its working fine.

DATA: request TYPE REF TO if_pt_req_request,
              event   TYPE tim_req_xfer_event VALUE cl_pt_req_const=>c_reqtrans_send.

    CALL METHOD cl_pt_req_badi=>get_request
    EXPORTING
      im_req_id  = me->req_id
    IMPORTING
      ex_request = request.

  CALL METHOD cl_pt_req_badi=>initiate_state_transition
    EXPORTING
      im_request    = request
      im_event      = event
*    IM_RET_VALUE  = 0
    IMPORTING
      ex_new_status = me->status.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear Friends,

I simulated the two level ESS leave request scenario and found that the issue is: even after the first level approver approves the leave request, the leave request is still appearing in his Work list(not as a workitem in UWL, but when he clicks other leave request work item, the old leave which he approved before still appears in the table(worklist)) and he is able to approve it again, In this case what is happening is the leave request status is again changed from SENT(which was previously changed by WF_BATCH) to APPROVED. Please advice how to resolve it.

vijy_mukunthan
Active Contributor
0 Kudos

This is because the next processor in the workflow is not cleared. Because of this its visible in the UWL. I have faced the same issues the solution is need to clear the next processor for that use this BADI PT_GEN_REQ enhance it and in the method FIND_RESP_AND_DEFAULT_NEXT_PRC clear the next processor. This will solve your issue.

Regards

vijay

Former Member
0 Kudos

Hi Vijay,

Thanks for your reply. Can you please let me know which parameter should I clear inside that method - FIND_RESP_AND_DEFAULT_NEXT_PRC. In my system there code inside this method is fully commented.

EX_RET_VALUE

EX_RESPONSIBLE_ACTOR

EX_DEF_NEXT_PROC_ACTOR

Regards

Former Member
0 Kudos

Dear sapient,

I had the same issue. Task is not clearing in the first approver's UWL.

Can you please advice me on this.

Awaiting for your reply.

Thanks in Advance.

former_member185167
Active Contributor
0 Kudos

Please open a new thread with the specifics of your problem.

Former Member
0 Kudos

Hi,

I have also simlllar issue work item status is not changing after posted in 2001 infotype and work item still in manager's inbox.

How did you slove this problem...??

Thank you!!!

Regards,

Srini

Answers (3)

Answers (3)

mohit_bansal3
Active Participant
0 Kudos

1. Interview File

2. CR Allocation File

3. RTM File

4. EXIT Workflow Compare

5. New Joiners Inside Barclays bay - follow up with jagdsih

Hi,

Needs to enque and deque Leave reuest before setting the status to "SENT".,

Write below Code

1. CALL FUNCTION 'ENQUEUE_EPTREQ'

    EXPORTING

      mode_ptreq_header = 'S'

      mandt            = sy-mandt

      request_id        = me->req_id

    EXCEPTIONS

      foreign_lock      = 1

      system_failure    = 2

      OTHERS            = 3.

2. <<<<< Now put your above code >>>>

3. Commit Work and Wait

4.  SET Next Porcessor

5.

  CALL FUNCTION 'DEQUEUE_EPTREQ'

    EXPORTING

      mode_ptreq_header = 'S'

      request_id        = me->req_id.

Regards,

Mohit Bansal

Former Member
0 Kudos

hi Mohit

Thank you for answering. I had done what you have mentioned about enqueue and dequeue.. but hasn't solved the issue... My boss is very angry about this issue and I don't know what to do. I have tested many things, but for example in 20 records, 2 records do not get the "SENT" status after the first approval by first manager in workflow.

If you don't have any problem with this workflow, please help me and let me know what to do to get this issue solved.

thanks in advanced.

bests,

Parisa

Former Member
0 Kudos

Could you post your code here?

The first thing is to put some kind of error handling to your code (if you don't have it). What if the enqueue doesn't work? How do you handle that? What if the status transition method call is not successful? How do you handle that? At least you should try to return the possible error messages somewhere (workflow container) to see why it didn't work, so you can solve it in future.


In general I don't like this approach that you change the status back from APPROVED to SENT. The reason is exactly that when it doesn't work, the leave gets posted without the required approvals. Even if it works 99% of time, it is not enough.


Regards,

Karri

Former Member
0 Kudos

thanks for answering quickly, Karri.

Actually, I controlled these things you mentioned by value of "sy-subrc", and whenever I check the container and workflow log in the message tab I get the bellow message:

"Method CL_PT_REQ_WF_ATTRIBS->ZCHANGE_STATUS executed successfully."

which shows me that it has successfully gone through the method during executing the workflow. But I do not get why it should not work sometimes...!

I have added this method in the standard class "CL_PT_REQ_WF_ATTRIBS".

here is my code:

Method ZCHANGE_STATUS.

call function 'ENQUEUE_EPTREQ'
     exporting
       mode_ptreq_header = 'S'
       mandt             = sy-mandt
       request_id        = me->req_id
     exceptions
       foreign_lock      = 1
       system_failure    = 2
       others            = 3.
   if sy-subrc <> 0.
     message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   endif.

*******************  getting leave req obj.
   CALL METHOD cl_pt_req_badi=>get_request
     EXPORTING
       im_req_id  = me->req_id
     IMPORTING
       ex_request = request.

********************** set the status to SENT
   CALL METHOD cl_pt_req_badi=>initiate_state_transition
     EXPORTING
       im_request    = request
       im_event      = event

     IM_RET_VALUE  = 0
     IMPORTING
       ex_new_status = me->status.
*************************COMMIT & WAIT
    COMMIT WORK AND WAIT .
*****************************   DEQUE THE REQUEST
      call function 'DEQUEUE_EPTREQ'
     exporting
       mode_ptreq_header = 'S'
       request_id        = me->req_id.


*}   INSERT


endmethod.


what is your idea then, if you don't agree with this idea of changing the status to "SENT" after first approval?


thanks a million.

Former Member
0 Kudos

Well, you check the sy-subrc of the enqueue function. Maybe that works always. But what about the actual method (initiate_state_transition) that does the job. You just trust that it works. Maybe in the problematic cases it returns new status APPROVED, so it didn't actually change the status back to SENT, but your method considers this as a success.

Regards,

Karri

Former Member
0 Kudos

so what is your idea?

Former Member
0 Kudos

Few ideas:

1) After method call to initiate_state_transition put a check "IF status NE 'SENT'", and inside that raise error. You probably want to return to possible error to the workflow (container or log). Now the problem might be that e.g. sy-msgid does not include the correct error message, but this might be worth to try. This is just to try to find the cause for the error. This will not fix the actual problem.


2) This might be a long shot, but what if you moved the whole code to separate class/method? Just create a new class (add IF_WORKFLOW interface to it) and then create new static/public method CHANGE_LEAVEREQ_STATUS to it. Add importing parameter REQ_ID to it, and then just cope paste your code there and do the necessary small adjustments. Now call this method from your workflow. I see that you have added a new method to the standard class. There should be no need for this. Perhaps your code is interfering the standard in certain circumstances. As I said this might be long shot, and perhaps not likely to work, but I have seen some strange locking behavior by the standard leave request solution, so nothing would surprise me...


Kind regards,

Karri 

Former Member
0 Kudos

thanks for your suggestion.

bests,

Parisa

Former Member
0 Kudos

Hi Vijay,

As you have mentioned, I have cleared those parameters but still sometimes we have errors. I mean sometimes, some requests' status do not reset to "SENT" after the first approval...

I appreciate if you answer my question. I have worked on this issue since 6 months ago and still could not solve it...

Thanks a million.

bests,

Parisa

Former Member
0 Kudos

Hi,

I have the same requirement of sending the leave workflow to muilt level, as you suggested i have enhanced the class CL_PT_REQ_WF_ATTRIBS with new method but when i am trying to create task with class CL_PT_REQ_WF_ATTRIBS the newly created method is not showing there. Can you tell me what is the problem.

Atul