cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid triggering of a workflow multiple times at the same time?

Former Member
0 Kudos

Hello Workflow Gurus,

This is the situation.

I have a Notify requisition creator workflow. This workflow is triggered only when a PO is completely released(this Po is created with respect to a purchase req). I have implemented multiple release strategy in my PO workflow. Meaning, if a PO is created for 5 million, 4 entries are created in the release strategy(P0, P2, P3 and P4). Some approvers have authorization to approve P0 and some have authorization to release P2 etc. Before an approver can release P4, P0, P2 and P3 shuould be approved first.

My problem is when a approver has auth to release both P3 and P4, and if he hits the SAVE button, it is completely released and 2 notify req workflows are being triggered. I use the release indicator = 'C' (completely released) to trigger thos notify req creator workflow. In this case both workflows are triggered at the same time and date. I somehow have to say if this is triggered at the same date and time, complete one workflow.

BTW, I am not using any user exit to trigger this. This notify req creator WF is triggering event is "RELEASED'. When pO is completely released, 'RELEASED' event gets triggered which caused the notify req creator WF trigger.

How can I accomplish this?

Thanks

Rachana

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Thanks for all the help.

Former Member
0 Kudos

Hi Rachana,

Another way you could acheive this is to use start conditions for your workflow. You could specify that your workflow should get triggered only for release codes = XX or release strategy = XX, etc.. This way even after 1 stage of approval, when the approver clicks on SAVE, the release codes change and because there is start conditions in the workflow that would prevent another instance of the workflow from getting triggered.

For example, in your case, I presume PO, P1, P2, etc are your release codes.

You can have a start condition in your workflow wherein you specify that the workflow should get only triggered for release code = P2 [assuming release code P2 is always the 1st stage of approval]. So, once the approver for P2 has completed and Saved, since there is a start condition, there wouldnt be any other workflow instance started. By this way, any stages of approval wouldnt cause another workflow to initiate.

Hope this is what you have been looking for ?

Satish

Former Member
0 Kudos

Hi,

We did have similar situation with one workflow that deals with WBS elements in project system. Unfortunately there is no simple solution to it. This is what we did:

1. De-link the original workflow from the original event (event linkage table)

2. Create a new workflow to store data, user ID, date, and time (which passed by the event to the workfow), in a custom table.

3. Link this new workflow with the original event (event linkage table)

4. Create a custom program to read data from the custom table at certain time interval, let say every 10 minutes for example.

4a. Trigger the original workflow only ONCE for each UNIQUE record using FM 'SWW_WI_START_SIMPLE'. This is the part that will prevent the original workflow to be triggered several times.

4b. Make sure you flag or delete those records (including duplicated records) which the workflow have been triggered for.

Hope it helps.

Former Member
0 Kudos

1. Create a method that calls function module SAP_WAPI_WORKITEMS_TO_OBJECT and associate it with a Background Standard Task.

2. When calling the function module you want to basically ask it: "Show me the running workflows of BUS2012 with key [key of the instance] and for only Workflow Template WS99999999 [substitute your notification template id].

3. After the call, inspect the table parameter "worklist". If there is only one row then you're good to go, otherwise sort the table (any order), read index 1, and if the workitem id (which is really the workflow id) is the same as your running instance, continue, otherwise cancel the workflow.

Unfortunately, this solution will permit two or more instances to start, which is not ideal. You just have to cancel all but one of them.

I can elaborate on the steps futher if you want to take this on.

Regards,

Tom Carruth