cancel
Showing results for 
Search instead for 
Did you mean: 

ESS BADI UWL

Former Member
0 Kudos

Hi Everyone,

We have certain leave types that require a mandatory attachment before they can be approved by the manager. The workflow is kicked off when the user clicks send and checks whether an attachment for that leave type is required. If an attachment is required then the workflow does not continue. The leave request sits in the requestor's universal worklist and only once it is actioned (an attachment is added) does it appear in the manager's universal worklist.

The problem I have is that if the manager wants to approve a different leave type that does not require an attachment that the employee has sent through, then when he goes through the approval process he can see and approve those leave types for that employee that have not had an attachment loaded. In other words, if I send through a leave request to my manager that requires an attachment it should not appear in my manager's universal worklist. It should appear in my worklist stating that I need to add an attachment before it can be approved. At this stage it also does not appear in my manager's universal worklist. So far this is all working correctly. The problem is when I send another leave request that does not require an attachment and my manager clicks on this request in his universal worklist to approve it, my other request (that should not appear in my manager's worklist) now appears and my manager can approve both - so he has now approved the leave request that requires me to add an attachment.

Is there a BADI that can limit what shows in my manager's approval worklist thus avoiding showing the leave type that does not have an attachment. Or is there a better way of handling this?

Regards

Mark

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mark,

In which place user will add the attachment?

Will it done after the workflow triggered or before that?

Thanks,

Viji.

Former Member
0 Kudos

Hi Viji,

The attachment is added after the workflow is triggered. If we use my example, I will apply for the leave and then a task will appear in my universal worklist saying I must add an attachment before I can send the request to my manager. This is all working just fine - the problem is that while the task sits in my universal worklist and has not been sent to my manager for approval, if my manager wants to approve a different leave request for me (one that does not require attachment) then when he clicks on this to view it, the leave request that still requires me to add attachment appears there as well and he can approve it without me adding the attachment.

Hope this helps.

Regards

Mark

Former Member
0 Kudos

Hi Mark,

Once the attachment is added to the workflow, check the workflow log.

Is the workflow container attachobjects has any value on it?

Thanks,

Viji.

bpawanchand
Active Contributor
0 Kudos

Hi,


the problem is that while the task sits in my universal worklist and has not been sent to my manager for approval,
 if my manager wants to approve a different leave request for me (one that does not require attachment) then 
when he clicks on this to view it,

If you can change the status of the leave request which is still not submitted by you by including the attachment into a DRAFT status then in this case the standard leave application wont try to read the request which are in draft state, it will read the request which are in SENT status. Just try this .

Since the request is not in the list so there wont be any issues further....

Regards

Pavan

Former Member
0 Kudos

Thanks for your help Pavan.

Are you talking about changing the workitem status via SAP_WAPI_SET_WORKITEM_STATUS?

Former Member
0 Kudos

Hi Mark,

For leave work flows there is a separate status. You can see the status in PTREQ_HEADER table. The thing is leave process is not really depend on workflow. If the leave status is 'SENT' then the leave request will be available in approvers's screen(Not in the UWL. It will be there in leave approval screen of App rover].

If you don't want to show the leave request to the Approver, then you can simply change the leave status from 'SENT' to 'Draft'.

But the issue is once the attachment added to the work item, you have to change the status again from 'Draft' to 'SENT'. Then only the approver can able to view the Leave request. At the same time you have to enable the work item in the UWL as well.

Thanks,

Viji.

bpawanchand
Active Contributor
0 Kudos

Hi,

No Iam not talkking about the workitem but the leave request that you send to the approver. Try to identify the leave type for which you require the attachment. and in the workflow before the workitem is sent for approval if the attachement is not included then change the status of the leave request to DRAFTor NEW , but as soon as the attachment is included to the req. then chnage the status of the leave request to SENT ...

That's all.

Regards

Pavan

Former Member
0 Kudos

Thanks Viji and Pravan.

I have done as suggested and using a method during the Workflow I change the status of PTREQ_HEADER and Req.STATUS to 'NEW'. This works fine in the Workflow and the values do change, the problem though is that in the database table PTREQ_HEADER for the workitem ID the status is still 'SENT'. Do I need to change this at the database level or do I need to try and move the action of calling the method sooner in the Workflow (although I have done this with no luck).

So will I need to read the database record and change the value to NEW in the database (if this is the only option) or do I change the values in the container during the Workflow?

Regards

Mark

bpawanchand
Active Contributor
0 Kudos

Hi,

You have to change the leave request status by using the class CL_PT_REQ_REQUEST method IF_PT_REQ_REQUEST~SET_STATUS, instantiate this calss by using the 32 bit guid that is in the workflow container REQ container element and by using the above method you can change to NEW.

Regards

Pavan

Former Member
0 Kudos

Hi,

You can change the leave req status as below. In workflow insert a background activity task step.

Standard class CL_PT_REQ_WF_ATTRIBS" has to be modified and an additional method "CHANGE_STATUS" ( This is the name of the method you should add. You can give any name as you like) should be included in the class.

This is the method which when called in background is used to change leave req status.

You would need an access key for the class to add the additional method.

Add the below code in your custom method. Note that this method has no parameters; it just uses the public attribute of the class "REQ_ID".

Method change_status.
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.
Endmethod.

Rgds,

Bharath

Edited by: bharath padmanabhan on May 11, 2011 4:00 PM

Former Member
0 Kudos

Hi Mark,

Table PTREQ_HEADER table has only the leave document status. Work item status will not stored in this table.

You can get the Leave document ID in the workflow container and pass into the table to get the relavant record.

Use the standard class to change the status to avoid the leave approval.

Thanks,

Viji.

Former Member
0 Kudos

Hi All,

Thanks for you continuing help.

I have tried to implement the suggestions that were made and you will see the code I am using below. This does not seem to be working though. I have a container that has the request ID that is required to instantiate (this is the same request id that you see in table PTREQ_HEADER). The status in this table stays as SENT and not DRAFT. Am I missing something here?

data:

pt_header like ptreq_header,

requestid type ptreq_header-request_id,

request type ref to if_pt_req_request,

c_req_draft type

tim_req_status value cl_pt_req_const=>c_reqstat_draft.

swc_get_element container 'PT_HEADER' pt_header.

if pt_header-status = 'SENT'.

swc_get_element container 'RequestId' requestid.

call method ca_pt_req_header=>agent->get_request

exporting

im_request_id = requestid

importing

ex_request = request.

call method request->set_status

exporting

im_status = c_req_draft.

endif.

Former Member
0 Kudos

Hi Mark,

For the status change you have to use the method 'initiate_state_transition' of class cl_pt_req_badi.

try the code from the below link.

Thanks,

Viji.

Former Member
0 Kudos

Hi Viji,

Thanks for the reply.

For what I am trying to do, do I need to just change the Document Status and not the Status Transition Event? The way I understand the suggestions is that I should change the document status from SENT to DRAFT so that it does not appear in the manager's approval list.

I have tried the suggested code but the document status in PTREQ_HEADER stays SENT. I have tried using the class CL_PT_REQ_REQUEST and method IF_PT_REQ_REQUEST~SET_STATUS and I have put in a "COMMIT WORK" but it is still not working. Please can anyone tell me if I am missing something.

This is a background method so I cannot even debug to see where it is going wrong although the log says that the method was executed successfully.

Regards

Mark

Former Member
0 Kudos

Hi All,

I am going to simplify this as maybe I am making it too complicated.

The suggested solution to my workflow issue is to change the status of the document to "DRAFT".

I have tried various codings without any luck as in table PTREQ_HEADER my document status still says "SENT'.

I have NOT tried initiate_state_transition method as I am unsure as to how I can change the status of the document to "DRAFT" by using the transition event "SEND" - as the method does not require the document status "DRAFT".

Is PTREQ_HEADER the right table for me to look at document status "DRAFT" or is it somewhere else?

How do I change the document status to "DRAFT" by using method initiate_state_transition? Or should I be using a different method?

Thanks for your help.

Mark

bpawanchand
Active Contributor
0 Kudos

Hi

I hope you might have observed the type of the variable EVENT in the below code snippet



Method change_status.

Data: request type ref to if_pt_req_request,
Event type tim_req_xfer_event value cl_pt_req_const=>c_reqtrans_DRAFT. "<--------- Event type

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.
Endmethod.

and then check it will work and I personlly used in different cases.

Regards

Pavan

Former Member
0 Kudos

Hi Mark,

try the function module PT_ARQ_REQUEST_EXECUTE to change the status of the leave.

Pass the input as below.

IM_REQUEST_ID --> leave request GUID

IM_COMMAND --> 'EXECUTE_SAVE'

IM_PERNR ---> Personnel nimber of leave requester

IM_MODUS ---> 'R'.

Thanks,

Viji.

bpawanchand
Active Contributor
0 Kudos

@ Vijji,

I think the FM u are suggesting might help us to either take some decision like Approve or Reject.. I do not think if it actually changes the status of the Request. If Am not worng..

Regards

Pavan

Answers (0)