cancel
Showing results for 
Search instead for 
Did you mean: 

Need to trigger a workflow for single time

Former Member
0 Kudos

Hi,

I have developed a workflow for Work Order that has three triggering events(Created, Changed, StatusChanged).

Whenever A work order has been created or changed or status has been changed the workflow will be triggered.

The Workflow basically call a program that takes work order number as input an create corresponding iDoc.

My problem is that when a user changed data and status of a work order at same time and hit save button two workflows has been triggered. One for changed event another for statuschanged event. For this, two duplicate iDocs have been generated.

And this need to be stopped. Is there any way to to stop creating duplicate iDocs by triggering the workflow for single time for this particular case?

Please help.

Regards,

Manas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I guess you should use check function modules in your event for this ... In your FM check if there is already an instance of your BO event in system if yes the check condition should fail...

Also add some time gap in the function module so that the earlier events is triggerred and workflow instance is created for the same...

Or

IN your workflow include a step to check if there is already an instance of the same workflow.. you can you a process control to delete logically delete the work item and complete the workflow...

Regards

Gautam

Edited by: gautam maini on Aug 22, 2011 5:26 PM

Former Member
0 Kudos

Hi,

Thanks for your reply.

But the problem is that, the time gap between the two triggered workflows is different in differnt times.

Some time it's 2 seconds some time 7 seconds or some time its 0 second. For this reason, I think the solution will not work.

If user changes a work order status and then data within little time gap suppose 5 seconds. Here 2 iDocs need to be creatred but the later one will not be created as it will find the related workflow instance.

Is there any other way to sort it out?

Regards,

Manas

Edited by: Manas Santra on Aug 23, 2011 9:59 AM

Former Member
0 Kudos

Hi ,

If you think that this solution is not working for your case...

the simplest solution would be to deactivate events for triggering your workflow... rather schedule a report which will determine the change documents and status changes since its last run and use SAP_WAPI_START_WORKFLOW to initiate workflow instance...

Regards

Gautam

Former Member
0 Kudos

Hi,

Scheduling a Report will also not be a solution here as the client wants to create iDoc on real time basis.

Regards,

Manas

Former Member
0 Kudos

Hi,

Basicaly the idea to handle this is that instead of using 3 events to trigger your workflow you should use 1( which will combine the trigger of all the events )...

Try this way ... for eg. by detecting if there is already a change in your Status of your document, the system does not trigger an event for change in document. For this you would have to deactivate change document event and introduce event trigger through FM...

Can you tell more about the BO being used here...

Regards

Gautam

Edited by: gautam maini on Aug 23, 2011 8:47 PM

former_member185167
Active Contributor
0 Kudos

Hello,

I don't understand. If there's a data change and a status change at the same time you just want one workflow.

But if there a data change and a status change 2 seconds apart you want two workflows?

These problems are usually solved as previously suggested - have either the workflow or the start condition check for an already-running workflow instance.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hi,

I have used Business Object BUS2007. I have created a subtype Z_BUS2007 and added three events Created1(created already exists but not working),Changed and StatusChanged.

For created1 and changed events I have used changed documet object ORDER in SWEC and for statuschanged event I have used Status Object ORI in BSVW.

Can you please provide solution in detail. Why should I deactivate change document event? If any one changed only work order data not status then how the workflow will be triggered. Here we cannot trigger event through FM.

Regards,

Manas

Former Member
0 Kudos

Hi Rick,

Let me clarify the scenarios in detail.

1. User opens a work order for change(IW32) then changes its status and data both and hit save button.

Current Result:

Two workflows are being triggered. From Changed event and statuschanged evet. The time diffrence between the creation of two workflow instances is diffrent in diffrent times like 2s,5s,7s etc.

Desire Result:

Only one workflow should be triggered.

2. User opens a work order for change(IW32) then changes its status only hit save button then again he opens the same order and changes its data only and hit save button within 5 seconds.

Current Result:

Two workflows are being triggered. First one for status change and 2nd one for data change. And this is also the desire result.

But if I choose the solution suggested previously the second scenario will not work. In this case only one workflow will be triggered.

Regards,

Manas

Former Member
0 Kudos

Hi,

I meant instead or triggering change through Change Documents you could use manual code to trigger when there is a change in the document...

Regards

Gautam

former_member185167
Active Contributor
0 Kudos

Hello,

Thanks for the detailed explanation.

1. User opens a work order for change(IW32) then changes its status and data both and hit save button.

2. User opens a work order for change(IW32) then changes its status only hit save button then again he opens the same order and changes its data only and hit save button within 5 seconds.

Why oh why would you want to differentiate between these two scenarios? What difference does it make to the business process? I'm not sure you can even differentiate between them. You could look in the change tables (CDHDR etc) and see if there's a difference and then build that into the logic. But again, why should these two scenarios be treated differently?

regards

Rick Bakker

hanabi technology

Answers (0)