Skip to Content
1
Former Member
Jul 30, 2013 at 04:43 PM

Singleton WF approach with bus1001006.viewcreated event(s)

121 Views

This a question which came into my mind while reading the excellent blog post

http://scn.sap.com/community/bpm/business-workflow/blog/2013/05/05/the-super-singleton-concept-for-workflow-instances-3-step-approach

of @Florin Wach

Please feel free to comment and provide advice!

Following scenario:

When a material is created, a workflow driven review process should start.

The workflow starts on event bus1001006.viewcreated because it must also start when later on another view is added to an existing material.

This event gets fired for every material view created, so n (n = number of created views) workflows are started simultaneously.

The first thing to do for the flow is to persist the data passed by the event into a z-table.

The first of the concurrent flows to do this is designated the "leading flow". All other flows recognize themselves as "non leading flows" and terminate after persisting their event data into the z-table.

So far so good. My problem is how to catch when all other workflows have persisted their event data so that the leading flow can continue.

Until now I'm simply using a Dummy Step with "requested start" = WI creation + 1 minute to give the other flows "enough" time to persist their data (which the leading flow must work with afterwards) and terminate.

Nevertheless, I'm not very happy with this approach since it may fail if the tRfc queue is congested.

Using the above mentioned singleton pattern the "non leading" flows would have to fire an event telling the "leading" flow that they have terminated.

The problem here is for the "leading" flow to know for how many parallel flows to wait for their termination.

I would have to find out how many material views were created respectively how many viewcreated events were fired for that material instance at the same moment.

Table MSTA unfortunately only has creation date but no time field, so this wouldn't work.

Do you understand my problem and have any advice?

Best regards...