cancel
Showing results for 
Search instead for 
Did you mean: 

Multi level approval in leave request workflow

Former Member
0 Kudos

Dear Experts,

I have copied std leave request wf 12300111 and extended it to 2 level approval. Once 1st level approver approves the request the status of request becomes APPROVED. So for 2nd level approver that leave line item is not displayed which means that only leave request with status SENT will be displayed to approvers and I have to change the status from APPROVED to SENT once 1st level approver approves. I found from SDN that PT_ARQ_REQUEST_PREPARE FM can be used to do this. Can you please tell me what I have give to IM_COMMAND input of this FM in order to change the status back to SENT.

Please share your valuable inputs if there is any other way to change the status from APPROVED to SENT.

KR,

Bharath

Edited by: bharath padmanabhan on May 8, 2010 9:33 AM

Accepted Solutions (1)

Accepted Solutions (1)

bpawanchand
Active Contributor
0 Kudos

Let me try to explain you breifly about how the leave request applied form portal or ESS wil behave, considering you have multiple levels

1. ONce you try to apply a leave from ESS then leae req status will be set to SENT status. and the workitem is created and kept in the appropriate managers inbox.

2. If at all manager takes a decision on the req the status of the req will be set to the decision he took, ( Approved, Rejected) , now if it is rejected then again the workitem will be sent back to the initiator or employee.

3. If it is approved then you would like to get the approval of second level manager, in this case what you have to perform is that you need to change the staus of the workitem or Request Status back to SENT, inorder to perform this what you can try to do is make use of the below code snippet, and this code must be included in the workflow, using a separate background task, which needs to be included after the Approval task of the workflow..



  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
    IMPORTING
      ex_new_status = me->status.

Former Member
0 Kudos

Dear Pavan,

Thanks a lot for your reply. When I debug the method where I have included your code snippet, I can see that I get the value of me->status as SENT. But still the value of Request status in workflow container as well as PTREQ_HEADER remains as APPROVED only. Can you please tell me where the new status SENT will be reflected.

KR,

Bharath

bpawanchand
Active Contributor
0 Kudos

First try to insert a commit work statement after the above code what i mentioend, even then ifthe version status is not getting chnaged to SENT then, i think you have to try with the below code snippet

after type casting the request CL_PT_REQ_REQUEST, in this class you have the methods, by which the request can be cloned to new or current or old.

so you need to make use of the CLONE_TO_NEW and check.


 DATA: request TYPE REF TO if_pt_req_request,
       lcl_req_request  TYPE REF TO cl_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.

lcl_req_request ?= request.

 CALL METHDO lcl_req_request->clone_to_new

commit work.

former_member184504
Participant
0 Kudos

Hi Pavan,

Even I have the same requirement to go for multilevel Leave approval, the thing that confusing me is that

in which method of class CL_PT_REQ_WF_ATTRIBS do I have to write the code snippet given by you.

Please reply.

Former Member
0 Kudos

This message was moderated.

prajyotp_demapure
Participant
0 Kudos

hello Pavan,

Can you please guide me where exactly I have to write the code step by step.

May I have to create new 'Z' class from standard one.

Please guide me I went through many threads but not getting where exactly I have to write the code and how to use it.

Thanks & Regards

Prajyot

Former Member
0 Kudos

Hi,

You can do as below,

1) Create a BOR Method or method in your custom class and add the code snippet as recommended by Pavan.

2) You have to call this method in a activity step (background) immediately after the activity step for 1st level approval. This is because after 1st level approval the status of leave request will be APPROVED. Then your method will switch it from APPROVED to SENT.

3) Note: If you have muti level approvals, make sure you call this method after every approval activity step. Only then the workitem will be available for approval for the subsequent approvers.

Please let me know if you have any queries.

Best,

AWF

prajyotp_demapure
Participant
0 Kudos

hi ,

Thanks for the response.

I did whatever you said, but getting error. Attaching the error screen shot please check.

Let me explain what I did.

1.copied standard task : 12300097

2.copied standard class :CL_PT_REQ_WF_ATTRIBS

3.Created ZSTATUS_CHANGE method in copied class ZCL_PT_REQ_WF_ATTRIBS and written the code given by pavan.

---------->No Parameters. If we have to mention the parameters please tell me.

4.Inserted Activity just after 1st approval with copied standard task,class and methodin background processing.

Am i right,please correct me if anything wrong.

thanks & regards

Prajyot.

prajyotp_demapure
Participant
0 Kudos

Hi pavan,

I'm using the code given by you,but facing one problem,in background processing we have to make the method as STATIC and in static method "me->req_id" is not possible.

So please tell me what code I have to write instead of "me->req_id" or to fetch the document ID i.e request id.

Thanks & Regards,

Prajyot.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Here is an example about how to change a status of a leave request (in this example the status is changes to APPROVED - but the idea is the same).

DATA:

request TYPE REF TO if_pt_req_request,

event TYPE tim_req_xfer_event VALUE cl_pt_req_const=>c_reqtrans_approve,

lv_status TYPE tim_req_status.

*Request object

CALL METHOD cl_pt_req_badi=>get_request

EXPORTING

im_req_id = me->request_id

IMPORTING

ex_request = request.

*Change status of 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 = lv_status.

Regards,

Karri

Edited by: Karri Kemppi on May 8, 2010 1:30 PM

Edited by: Karri Kemppi on May 8, 2010 1:31 PM