Skip to Content

First of all, the worst thing you can do is to program a ‘Wait up to x seconds’ within a BOR Method!  Imagine that 30 workflow instances are started and start executing the “wait up to” at the same time (eg: after event queue processing), this will cause your eg 20 work processes to wait and therefore a system standstill for a few seconds. 

In any case ‘wait up to x seconds’ is BAD PRACTICE!

In order to implement a “Wait” within a workflow, you might use different ways to implement!

How to solve this correctly?

1) The first goal should be to avoid the use of any ‘wait’-principle.  Typically, one should be able to rely on the SAP standard principles on synchronous Tasks (where the workflow only continues after task is completed = DB update should be finished) or asynchronous Tasks (where the workflow continues after a Terminating event indicating the DB update was finished).

Unfortunately, in some (rare) cases the update to DB was not completely finished therefore they might require on of the below options:

2) In case you can depend on a SAP Standard (or custom) event, please implement a ‘Wait for Event’ within your workflow
image

This principle is always good practice since here your workflow becomes also reactive on Events from outside your workflow (eg: when a delete on an object is triggered, your workflow can close down and therefore becomes self regulatory)

2) If you want to start a workitem and you want to be sure that some background processing prior to this step is finished, you might implement a ‘Condition on Create Workitem’.
image

The only thing you need here is an Attribute on a Business object that will be filled and which can be then evaluated against the condition value.  The job (scheduled via SWU3) will evaluate this condition upon execution.

3) The last option (but not always bullet proof) is to create a ‘Requested Start’ Deadline on the Workitem.

image
This will create a Delay in the start of your Workitem based on the given timing you’ve set!

Option 1 and 2 are the best options and most bullet proof, if you can solve it by implementing a ‘Wait for event’, please do so…  If not, then you probably can solve it with the ‘Condition on Create Workitem’

I hope these tips will help us to create better designed and more performing workflows!

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Susan Keohan
    Hi Pascal,
    Thanks for the nice blog.  I think that ‘Wait for Event’ would solve so many issues, I am glad to see you publicize this.

    Happy WF-ing,
    Sue

    (0) 
  2. Kumud Singh
    Hi Pascal,
    I had a requirement wherein the workitems in the user’s inbox should not be closed until he enters a particular field value.
    e.g. the user is shown with fields like NAME,AGE etc. Now if user only enters AGE and not name the work item should remain in his inbox.

    I had used LOOP UNTIL step to resolve this? Do you have any suggestions if it could have been in a better way using any of the terminating events etc.Thanks. With Regards, Kumud.

    (0) 
    1. Pascal Decock Post author
      The best way to solve this is directly in the Object Method itself!  First, make sure you have a Method with a Result type (eg: Std SAP method FORMABSENC.APPROVE).  You could program your method sending back a result depending whether ‘DATACOMPLETED’ and another result value indicating ‘NOTALLFILLED’.  Then, it is just a matter of De-activating the result outcome in the workflow on the result value ‘NOTALLFILLED’.  So, when the user then fills all values as you want, the workflow will continue as it is designed in the WF.  The other situation ‘NOTALLFILLED’ will not complete the workitem, therefore the workitem stays in the inbox of the user (in status ‘In Process’)

      It’s not such a good idea to build a ‘loop’ around the step in order to keep the workitem open!

      (0) 
  3. Harsh Bhatt

    Hi Pascal,

    Nice blog.

    I have one doubt though, do we have any mechanism (step) in SAP workflow using which we can make workflow to wait in background and trigger that step onward on some event occurrence.

    (0) 
  4. KIRAN RAJAN

    Hi Pascal,

    I have doubt , in my workflow is triggering from two different events from different BOR (ISUPOD DEVLOC).In the workflow i am waiting for events in the BOR ISUPOD.If the workflow is started from the DEVLOC event ,then wait events goes to error state  bcoz ISUPOD is not initiated at point.Can you please suggest me how can i handle when the workflow is triggered from the DEVLOC triggering event

    (0) 

Leave a Reply