cancel
Showing results for 
Search instead for 
Did you mean: 

Custom workflow trigerring twice for same event

poonam_chawla
Explorer
0 Kudos

Hello,

I have one custom workflow for creating VBD documents.When user is creating documents,workflow gets triggered for the first time.

In the last task of the workflow where VBD document is getting released, event CREATED gets triggered again and workflow gets executed second time.

Would you help me to understand why workflow gets triggered twice?

Accepted Solutions (1)

Accepted Solutions (1)

anjan_paul
Active Contributor
0 Kudos

Hi,

  If event triggered twice, you can handle assure workflow trigger only once usin Check FM . In the Check Fm you check any instance is exist or not usin SAP_WAPI_WORKITEMS_TO_OBJECT. If  instace is there then raise excepton

Answers (7)

Answers (7)

poonam_chawla
Explorer
0 Kudos

Hello,

Thanks for your helpful answers.

But the issue was within the RELEASE method of VBD document.Standard BAPI_SINGLEREMUREQS_CHANGEMULT used in release method again triggers CREATE event for VBD document.

Functionality has been changed and appropriate methods are used so that workflow is not triggered again.

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Further to the above suggestions - have you turned on the event trace temporarily to check what is happening? If the event is actually being raised  twice you should see that clearly in the event log in SWEL (use transaction SWELS to turn it on).

The workflow will be triggered for each event unless you have a start condition or an event check function to prevent it.

You really need to know how the events are getting triggered and the event log should give you some clues about the calling application as well. Raising the same CREATED event for the same standard document would be a bug if its being raised by standard SAP. That said, bitter experience suggests it's much more likely to be a bad bit of custom code or a double entry in the configuration or a dodgy workflow design (e.g. if one workflow is raising the duplicate event).

But the event log is worth trying as a first step to get some clues as to the cause.

Former Member
0 Kudos


Poonam Chawla wrote:

Hello,

I have one custom workflow for creating VBD documents.When user is creating documents,workflow gets triggered for the first time.

In the last task of the workflow where VBD document is getting released, event CREATED gets triggered again and workflow gets executed second time.

Would you help me to understand why workflow gets triggered twice?

As you said in last step when document get released event CREATED gets triggered again. Please share have you written custom code to trigger event or SAP its standard process ? The code which trigger this event get re-executed during release of VBD document. If its custom code then put some condition before event trigger else you have to follow any one option:

1.) Put some check FM in T-code SWE2 to avaoid retrigger.

2.) Else you can change the CREATED event with some custom event name and put the triggering code in some exit with proper condition.

BR,

Prakash

I042439
Employee
Employee
0 Kudos

Hi Poonam

"In the last task of the workflow where VBD document is getting released"

is it a background task? If yes, the event would show user WF-BATCH and you can easily bypass triggering of the workflow using a start condition checking Workflow Initiator <> USWF-BATCH.

If it is not a background task, then it gets executed by the user who executes the work item. Then we will need more information on the event triggering technique used  - is it by way of enhancement and coding or some other process is followed?

Regards,

modak

Former Member
0 Kudos

How does the workflow get triggered at the first time? With event CREATED or what?

Is there a link (or links) between the event and the workflow in transaction SWETYPV?

If the CREATED event starts the workflow (event linkage defined in SWETYPV), then there is your answer why the workflow gets started second time. Then you should ask that why the workflow is triggering the CREATED event at the end of the workflow. Without knowing the details of the process (or if this is a standard or custom workflow) this doesn't sound right.

Regards,

Karri

ACurtis
Explorer
0 Kudos

More information needed I think.  What is a VBD document? Is it a std SAP document?  Other thoughts might be use a Condition SWB_COND to limit when something is triggered or a Check FM on the Event (SWETYPV) maybe. Or if a VBD document is a std SAP document it might be a SAP message or if it's bespoke, then change the trigger code.

ideas to have a look at.

A

gaurang_gujar
Active Participant
0 Kudos

Hi Poonam,

I would request you to please check the triggering event in the workflow

Regards,

Gaurang