Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Reject Workflow Item Via BAPI

Former Member
0 Likes
3,779

We are trying to implement functionality to reject a workflow item. We are using a BAPI to release and item.

Can you set the workitem status to rejected with SAP_WAPI_SET_WORKITEM_STATUS?

We attempted to use SAP_WAPI_REJECT_WORKITEM but the funtion states that our workitems cannot be rejected because it is the wrong type.

Any suggestions would be appreciated.

1 ACCEPTED SOLUTION
Read only

ramki_maley
Active Contributor
0 Likes
3,235

Stephen,

A workiten can only be rejected if the corresponding step in the worklfow definition is defined as 'can be rejected'. You can try the 'CANCEL'status, this logically deletes the WI.

Cheers,

Ramki Maley.

Hi Mike/Steve,

I think your problem could be that you are trying to reject a decision task where the agent has to choose to either release or reject the PR by clicking om a button and then the next step in WF may probably be updating the PR accordingly.

Rejecting a WI is completely different and SAP may not allow rejection of a decision step. I think there is another WAPI FM to process a decision step. I do not have access to the system at this time. I will update this post when I find it.

Cheers,

Ramki Maley.

17 REPLIES 17
Read only

ramki_maley
Active Contributor
0 Likes
3,236

Stephen,

A workiten can only be rejected if the corresponding step in the worklfow definition is defined as 'can be rejected'. You can try the 'CANCEL'status, this logically deletes the WI.

Cheers,

Ramki Maley.

Read only

0 Likes
3,235

Can you tell me where the "can be rejected" definition is located on the workflow steps?

Read only

0 Likes
3,235

If you open your workflow in workflow builder(Tcode SWDD) and select the Activity that you intend to add the rejection to, then you will see on the right hand side, a checkbox that says 'Processing can be rejected'. Check that and you will be ready to use that feature.

Read only

0 Likes
3,235

Hi....we set the flag.

We using this BAPI SAP_WAPI_REJECT_WORKITEM. The item doesn't reject. The error returned is "Selected function is not available for work item".

We execute the SWW_WI_REJECT and the following error is returned...000000007014: Rejection not allowed

Any ideas?

Read only

0 Likes
3,235

Have you refreshed the buffers (txn SWU_OBUF)after the change to your workflow? If not, do so.

Can you reject this wi from the agent's SAP inbox?

Ramki Maley.

Read only

0 Likes
3,235

Hi Ramki,

I am working on this with Steve as well. I did try to refresh the buffers and that doesn't seem to have changed it either.

It's possible that we may be looking at this wrong. We are trying to use this functionality to reject purchase requisitions. I don't know that we should be trying to reject the workflow item or if there is another approach we should take. Any thoughts on your end?

Thanks in advance!

Mike

Read only

0 Likes
3,235

Hi Mike,

We are also using the purchase requisitions workflow and it is working fine. Right now I don't have the details, but I can find out on Monday when I get back to work. I am not sure but, this may also be tied up with the release strategy. Look in configuration about that topic to see if there is any relevant config that needs to be done.

Regards,

Srinivas

Read only

0 Likes
3,235

Hi Mike/Steve,

I think your problem could be that you are trying to reject a decision task where the agent has to choose to either release or reject the PR by clicking om a button and then the next step in WF may probably be updating the PR accordingly.

Rejecting a WI is completely different and SAP may not allow rejection of a decision step. I think there is another WAPI FM to process a decision step. I do not have access to the system at this time. I will update this post when I find it.

Cheers,

Ramki Maley.

Read only

0 Likes
3,235

In looking at this, the workitems are of type W of dialog and the processing rejectable property has been selected in the workflow definition for the related step.

In the SAPGUI inbox, the reject execution selection is disabled under the options menu.

Shouldn't this be enabled and rejectable from the SAPGUI? I assume this is why the functiona module is failing.

Read only

0 Likes
3,235

Hi Stephen & Mark,

I think you should check something first without going any further - is the step which you need to execute a user decision step or an activity (user decision has the question mark and the play button signs, activity only has a play button)?

If it's an activity, I'm pretty sure the task behind the step points to a release method of the PR object. This means that whenever the step/task is executed, the user is brought to a standard program or transaction where s/he can release or reject the PReq. Based on the user option, the PR is then rejected or released, the task gets executed and the workflow continues.

Without knowing your current workflow solution details, one option is to make this step/task so that it completes also when the PR has been released or rejected, not only when the task is executed. In other words, the task is waiting for an event and could complete when it is received, regardless of if it was really executed by the user.

So, in conclusion, if you have a terminating event defined for the workflow task (or if you will define it), you can complete the task directly by releasing/rejecting the PReq. Just call the correct release/reject method of the PReq object (e.g. bus2009->release) and as a result the Preq gets rejected or released, task completes (since it received the terminating event) and the workflow can continue.

But as I mentioned in the beginning, this is just one solution alternative, please provide more information about your current wf config (step type, task used, terminating events used, method called etc.) for us to get the complete picture.

Hope this helps,

Mikko

Read only

Former Member
0 Likes
3,235

I believe this is the information you are asking for...

Step Type – Activity

Task Used – TS00008014 - Requisition release refused

Terminating Events – I can’t find any

Method Called – None

Read only

0 Likes
3,235

Is the missing terminating event the issue?

Read only

0 Likes
3,235

Hi Stephen,

just to make things clear, are you working with the standard workflow WS00000038? And you would like to execute the task TS00008014 from outside the workflow?

The task TS00008014 points to method BUS2009-INFORELEASEREJECTED (2xclick on task to find this in the workflow builder), which just calls transaction ME52 to inform the user that the item has been rejected previously in the workflow.

Frankly I still don't fully understand the requirement you have.. Would you like to make the task complete in the background without the user knowing about it? Or do you want to reject the actual purchase requisition item in the background and let the workflow act on this somehow?

Best regards,

Mikko

Read only

0 Likes
3,235

Hi Mikko,

First of all, thank you for the help you have provided thus far. I think it may be a good idea to let you know better what we are trying to do.

Our requirement is to create an interface using Enterprise Portal for approval/rejection of purchase requisitons. Up to this point, we are using BAPIs to get purchase requistion details and to approve them. These two alone do not fullfil our requirement as we also need to reject purchase requisitions with this interface. The way our workflow is setup (which is the way i believe many others are setup), is that requisitions are approved on an item by item basis. Along with this, the release strategy that is setup is based on Plant, Cost Center, Amount. The BAPI we are using to Release or "Approve" purchase requisitions is BAPI_REQUISITION_RELEASE. Originally, we wanted to have a similar BAPI to process the rejection of purchase requisitions but we have been unsuccessful up to this point.

I think this is maybe where the confusion came to be. I am not sure if the Workflow item rejection is the correct path to go down, but if it works then that would be good too.

So to answer your second question, yes we would like to reject the actual purchase requistion item and then have the workflow take over from that point.

I hope this helps with understanding our requirements better. Thanks again for your help on this matter.

Regards,

Mike

Read only

0 Likes
3,235

Hi Michael,

I'm glad to be of help, having searched your name on Lookup I actually believe we are working for the same company

But thanks for clearing the scenario. The problem you have here is how to make the workflow react to the approval/rejection you do to the preq item.

Because you are not executing the approval decision work item but you are modifying the underlying business object to do the approval externally to workflow, you need some way to make sure the pending approval decision work item gets completed as well. Otherwise the approval decision work item will remain in the user's inbox forever and the workflow can't continue.

This work item completion can be done by putting in a terminating event to the task in question. The terminating event would thus listen for any approvals/rejections to the work item and complete the task if the approval has been done externally from a BAPI. Then the workflow would continue.

I have another question though, why are you not using the standard UWL (universal worklist) in EP to fulfil the requirement? There the user could just click on approve/reject, the Preq item would be updated and the workflow could continue in the backend system.

Hope this helps,

Mikko

ps. if I just don't get it or if you want to show something else, you can also send me an email to my company address if I recognized you correctly in the beginning..

Read only

0 Likes
3,235

Hi Michael,

I am assuming you are using the WF template 00000038 or a copy of it. The first step in the workflow Release Requisition is an asynchronous task listening for terminating events Released, Canceled, Rejected and Significantly Changed. When an item is released with BAPI_REQUISITION_RELEASE, the Released event is triggered. This completes the Release Requisition step and the WF proceeds to the Positive Confirmation step which I think displays the PO item to the initiator. However one can only reject the PR item by executing Release Req. WI in the inbox. I was not able to find a BAPI or FM to reject the PR item in the background or remotely in our 6.20 system. You may request SAP for such functionality to be developed since Release & Reset Release are made available.

As Mikko suggests, your best bet is to go for UWL.

Cheers,

Ramki Maley.

Read only

Former Member
0 Likes
3,235

Any resolution to this? Please help as I am facing the same issue!

Thanks.

EnriqueL