cancel
Showing results for 
Search instead for 
Did you mean: 

workflow in event queue based on a deleted object

matias_z
Participant
0 Kudos

Hi all,

I'm facing a problem with a workflow that goes to the event queue, meanwhile the object is deleted and then the WF is released from the event queue in Error. The WF is based on the BO BUS2032 (sales order).

Here are the steps:

1-Sales order created or changed --> event generated --> WF linked to that event goes to event queue

2-Meanwhile the WF is the event queue waiting to be released, the sales order is deleted

3-The WF is released from the event queue but in ERROR status (this is because the BO instance does not exist anymore)

In this scenario, is there a way to end the WF with CANCELLED status instead of ERROR? is there anyy FM or exit you know ehere I can check if the BO still exists once the WF is released from the event queue?

Thanks!!!!!

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member185167
Active Contributor
0 Kudos

Hello,

I think you're mixing up some terminology here.

I suspect the problem is that an event to start a workflow is put in the event queue, but by the time it is released the underlying object instance (eg sales order) has been deleted.

If it is a custom workflow, I would build in a check at the beginning to see if the object instance still exists. If a method for this isn't available, then it shouldn't be too hard to make one yourself.

I agree with Karri - event queues are a hassle. You woudl really need to have an enormous volume of events and workflows to even begin considering using them.

regards

Rick Bakker

hanabi technology

matias_z
Participant
0 Kudos

Thanks Rick and Karri. I'm checking if the object is initial at the beginning of the WF, so I can finish it.

Thanks!

Former Member
0 Kudos

If you are not familiar with check function modules, just Google them with "check function module in workflow". At least I get a nice example as a first hit.

Regards,

Karri

matias_z
Participant
0 Kudos

The check FM is executed when the linkage between the event and the WF go to the event queue, not when the WF is released from the event queue.

I already tried that solution.

Former Member
0 Kudos

Some questions/options:

1) How/why does the WF go into an error exactly? Does it try to complete the first step? What if you put a condition step as a first step in the WF and check whether the object is initial and if it is, then cancel the workflow.

2) How about deleting the event from the queue from some user-exit/badi in the sales order deletion. If I remember correctly the events when queued are in table SWEQUEUE. Probably you can find some function to delete events from the queue. Take a look for example function SWE_EVENT_QUEUE_DELETE to see the idea. Or take a look into transaction SWEAD. There you can delete events from queue. Check what it does and do the same in your code.

3) Is this really a big problem? Are there so many sales orders deleted?

In general I think that the whole event queue seems to many times cause lots of problems (the event queue job disappears, WFs will not get started, and whatever.). I try to avoid using it.

Regards,

Karri

Former Member
0 Kudos

Hi,

Have you checked the possibility to use check function module for events? You can define a so called check function module in SWETYPV for events. Inside the function you could check if the object is still valid (execute some sales order existence check BAPI or whatever), and if not, then raise an exception => the workflow will not start at all.

Although I am not completely sure if I even understood your problem correctly. You say "a workflow that goes to the event queue". Workflows do not go into event queue, or do they? Aren't they events that go into event queue? And after the event is "released" the workflow will start based on that event.

Anyhow, if you try me above solution, I am not completely sure that in which point the check function module will be called. Is it called already when the event is created, or only after it is released from the queue. If it is the first option, then my solution will not of course work.

Regards,

Karri