cancel
Showing results for 
Search instead for 
Did you mean: 

Restart Workflow for condition

arsiasmi
Explorer
0 Kudos

Hi

I have completed the workflow design, however i need to reset the workflow to the starting step if there are any changes in the records.It has to be a background task where the task will check the change in fields from CDHDR/CDPOS, then is should trigger reset of workflow.

Any help will be appreciated.

Thanks


Accepted Solutions (1)

Accepted Solutions (1)

pokrakam
Active Contributor

Usually I prefer to cancel the old and start a new workflow.

Add a CHANGED event both as a triggering and a terminating event. Every time there is a change, this event will cancel any active workflows and start a new one. It makes logging simpler, as you will see multiple workflows in a status CANCELLED and one COMPLETED.

You can link events to change documents using tx SWEC. Plenty of documentation and info on here on how to do that.

mateocanoc
Discoverer
0 Kudos

Hi Mike, I know it is an old post, but, I have one concern about your advice... If the same event (CHANGED) trigger the workflow and terminate it..When the workflow starts it not going to end immediately?

Thanks in advice!

pokrakam
Active Contributor
0 Kudos

mateocanoc no, because the terminating event has to happen after the WF has started.

In technical terms, once all listening event receivers that exist at the time the event is processed are triggered, the event is ‘consumed’ and complete.

Answers (2)

Answers (2)

egor_malov
Contributor

Hi, Arsalan,

One of possible ways is to use BOR events.

It is possible to:

arsiasmi
Explorer
0 Kudos

Hi Egor Malov

Thank you for response. However, your reply does help in understanding the workflow but my requirements are different. I have designed 2 workflows, one will be triggered when record is created & the second will be triggered when the record is changed. My requirement is, when the record is changed, the workflow that is triggered on create event should get reset i.e. all work items in SAP Inbox related related to the record should be cleared.

egor_malov
Contributor

Hi, Arsalan,

I think I get the idea better now - when the record has changed, nobody wants to know it had been created anymore.

Trying to get this requirement closer to SAP workflow features and terminology, I think, what you could do to the first (i.e. the one that runs at creation) workflow instance is *cancel* it (with all its workitems).

If you choose the BOR events way of implementation, you can 'cancel workflow' just as easy as you can 'restart workflow' (as desribed above): it is just another option of the very same drop-down field.

If you choose another approach you can use the SAP_WAPI_* function module, that cancels a workflow.

*one more note on BOR events: if you work with some standard business object, it is possible that it is already capable of firing BOR events like CREATED or CHANGED. It can take some configuration to enable. Check this, and you'll probably won't need to process change documents.

Hi ,

Wait for the change event in a branch of fork of Create Workflow.It will get logically deleted

Thanks

arsiasmi
Explorer
0 Kudos

Hi Ram

Please help in case you have some documents to proceed.

Kind regards

Arsalan A

Hi Arsalan,

Its simple,In the create workflow just add a fork with 2 branches and make 1 necessary,one for the Wait step and the other for your current flow.

Any standard Documentation on Fork and Wait will help you here.

Thanks

arsiasmi
Explorer
0 Kudos

Hi

Thank you Egor & Ram.

I resolved it by using WAPI's

1--> SAP_WAPI_WORKITEMS_TO_OBJECT

2--> SAP_WAPI_WORKITEM_RECIPIENTS

3--> SAP_WAPI_WORKITEM_DELETE

Regards

Arsalan

former_member186746
Active Contributor

Hi,

It would be better to model the solution in your workflow template by using forks and events and wait for events. The triggering can then be done with SAP_WAPI_CREATE_EVENT.

Kind regards, Rob Dielemans

arsiasmi
Explorer
0 Kudos

Thank you Rob,

Please help me with a proper document(if available) to proceed.

Kind regards

Arsalan A

arsiasmi
Explorer

Indeed using fork & wait proved to be easiest solution.

thank you