Quantcast
Channel: SCN : Unanswered Discussions - SAP Business Process Management
Viewing all articles
Browse latest Browse all 3160

Leave request STATUS not getting updated in Multi-level workflow

$
0
0


Hi Experts,

 

I have copied the std leave request workflow and extended it to 2 levels.

After the first level approver approves, I need to change the status of the leave request back from APPROVED to SENT.

 

For that as suggested in of the threads, I included a piece of code in a class's method which I am calling in a task after 1st level approval.

 

Following is the code:

 

   DATA: request    TYPEREFTO if_pt_req_request,
        lcl_req_request  TYPEREFTO cl_pt_req_request,
        event_sent TYPE tim_req_xfer_event VALUE cl_pt_req_const=>c_reqtrans_send,
        lv_status  TYPE tim_req_status.

  im_request_id = document_id.

*-- Enqueue the request.
  CALLFUNCTION'ENQUEUE_EPTREQ'
    EXPORTING
      mode_ptreq_header = 'S'
      mandt             = sy-mandt
      request_id        = im_request_id
    EXCEPTIONS
      foreign_lock      = 1
      system_failure    = 2
      OTHERS            = 3.
  IF sy-subrc <> 0.
    MESSAGEID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*Request object
  CALLMETHOD cl_pt_req_badi=>get_request
    EXPORTING
      im_req_id  = im_request_id
    IMPORTING
      ex_request = request.

*  lcl_req_request ?= request.
*
*  CALL METHOD lcl_req_request->clone_to_new.

*Change status of request
  CALLMETHOD cl_pt_req_badi=>initiate_state_transition
    EXPORTING
      im_request    = request
      im_event      = event_sent
    IMPORTING
      ex_new_status = status.

  COMMITWORK .

**-- Dequeue

  CALLFUNCTION'DEQUEUE_EPTREQ'
    EXPORTING
      mode_ptreq_header = 'S'
      request_id        = im_request_id.

 

 

Now when  I am raising a request and approving it from the 1st level, the status of the leave request is still appearing as APPROVED in the log.

Due to which when I am logging in as 2nd approver, I am not able to see the leave request details on clicking the work item in his UWL.

It says 'Your worklist is empty'.

After observation, I found one more thing that in table PTREQ_HEADER, when the request status is changed in workflow after 1st approval, a new record for that leave request id is created with new version number 2. Hence, the older version 1 has status SENT now, but the newer version 2 has status approved. And the workflow log reflects the leave request version as 2 and status as APPROVED.

 

So ultimately the status of req remains APPROVED and not SENT.

 

Help needed.

 

 

Regards,

Pranita

 


Viewing all articles
Browse latest Browse all 3160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>