cancel
Showing results for 
Search instead for 
Did you mean: 

Issue using ParForEach block in workflow template

jamespallett
Explorer
0 Kudos

Hi there

I am having some issues setting up dynamic/parallel approval in a workflow template, every time I get one bit working I seem to find another issue and I'm hoping there are some experts here who can help.

I've knocked together a quick diagram of what my workflow needs to do, but to summarise:

My workflow starts when an invoice item is price blocked, and it uses multiple account assignment (this bit is OK);

I have created a new task to find all of the approvers based on the account assignment, and then fill a table called ApproverTable in the workflow container (again, all fine, in my example it finds two approvers). At this stage I capture the number of approvers and set a container variable called Counter to the number of approvers (so, again this is 2 in my example);

Then for each entry in ApproverTable, it should send a decision step to the financial approver who decides whether to approve or reject the price variance. To achieve this I have used a block step, set it to ParForEach, and on the Parallel Processing tab I have entered my multiline elemenet as ApproverTable (I am getting a task per approver);

If the approver rejects the variance, it should send an email to the requestor and loop back to the start (seems OK);

If the approver accepts the variance, they click Approve. At this stage I am using a container operation and subtracting 1 from the value in Counter;

I have a loop until step that checks if the value of Counter is equal to zero. If so, the price block is removed.

The issue I have is that the Counter never seems to get to zero when I use it in the block. It's as if the counter is 2 in each step, and so it's always 1 at the loop until check. I then end up in an endless loop, whereby it just restarts back at requester reviews bit...

Does anyone have any idea where I might be going wrong please?

Accepted Solutions (1)

Accepted Solutions (1)

bpawanchand
Active Contributor
0 Kudos

Hi,

At first, what I understood is if one of the parallel steps has been approved and then you would like to close the other approver step. Instead of block step the step which is used to capture the action of the end-user I would make use of the multi-line container element which is located under the Miscellaneous tab. Here you also get the same behavior what you were trying to achieve. However, comparing with the block step in this approach you have a possibility to define the end condition. This is more or less like the same behaviour that we define for the fork step where we end up defining the end condition. So if any one of the work-items action is approved then complete the other work-items.

Regards

Pavan Bhamidipati

jamespallett
Explorer
0 Kudos

Hi Pavan

Sorry, the block should only be removed once all of the approvers have agreed the price-variance.

Unfortunately the costs could be split many ways, so I don't know until runtime how many approvers there will be. Looking at the table RBCO (account assignment for incoming invoices), there are a lot of examples in the production environment where there are more than two users...

Thanks

bpawanchand
Active Contributor
0 Kudos

Hi James,

I forgot to include the screenshot in the above reply.

Oh yeah, I completely agree with you only if all the work-item are approved then you would like to move ahead otherwise you would still send the work-item back to the list of the user. My idea was to play around with the end condition of the step rather complicating the definition with a block step.

Regards

Pavan Bhamidipati

jamespallett
Explorer
0 Kudos

Thanks for the screenshot, Pavan.

Oddly enough I have been following the blog post from Anjan who has also offered some help:

https://blogs.sap.com/2013/06/06/dynamic-multilevel-approval-workflow-using-block-step/

I did try and change my workflow to use the Misc. tab, but didn't see the end condition there. I'll give it another try, anything to get it working at this stage, I've made 41 copies of the invoice to test it so far... 😄

jamespallett
Explorer
0 Kudos

So I took the block step out, and instead used the Misc tab on the decision step, and set the end condition to be &COUNTER& = 0.

If all the approvers approve the task, it works fine. If one of them rejects it, the loop starts again (as it should do), but as soon as one of the users clicks approve, the other task gets logically deleted - presumably because my counter is now equal to zero.

I tried to change the workflow again so that I set the value of COUNTER inside the loop, but when I do this it just gets stuck in an endless loop, and it keeps going round and round regardless how many times I click approve.

Any further suggestions please?

jamespallett
Explorer

Just to say that using the suggestion from Pavan, I have managed to get it working...

When I get the list of approvers, I set the container variable &COUNTER& to the number of approvers found.

I have then removed the block step and used the Dynamic Parallel Processing option on the User Decision task instead. In the end condition, I have set:

&COUNTER& = 0

or &ITEMREJECTED& = X

If the user clicks approve, I subtract 1 from &COUNTER&; else if they click reject, I have set the variable &ITEMREJECTED& to X. After the approve/reject step I have added a new condition that checks if &ITEMREJECTED& is equal to X, then:

  1. If true, I trigger the event to start the workflow again, but for the same invoice item; or
  2. If false, I release the block on the invoice item.

I've included a new diagram in case this helps anyone else who may be stuck with a similar scenario.

I have tested it this afternoon and if a user clicks reject, the current workflow ends and starts a new one (which is effectively what the loop was doing but in the same workflow). Thanks everyone for their input!

bpawanchand
Active Contributor
0 Kudos

Hi James,

Appreciate the effort and helping others with the idea and the solution you provided.

Thanks

Pavan

Answers (2)

Answers (2)

SamuliKaski
Active Participant
0 Kudos

The exit condition needs to be defined for the approval task, inside the processing block. You should realize that task start and exit conditions are handled by the workflow runtime like all other conditions, see the documentation for SWWCOND. I have always chosen to programmatically complete all tasks rather than waiting for the condition to be evaluated. The challenge with the workflow runtime is that it is asynchronous, you never know in which order the tasks get executed and when.

anjan_paul
Active Contributor
0 Kudos

Hi James,

Try to modify like this way. Instead of Counter , take a Boolean container element . Replace the Container operation step after Approve with setting the Boolean conterner element with X .

In the loop until step, check Boolean contaner element = X .

Please do this, and let us know.

Thanks,

Anjan

jamespallett
Explorer
0 Kudos

Hi Anjan

I thought about using a boolean at first, but the block should only be removed if all of the users approve the tasks. Or is the boolean checked per approval task? Sorry, have no workflow experience so I am trying to muddle my way through! 🙂

Thanks