cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle Work item Loop inside Custom Flexible Workflow

mayurespatil11
Explorer
0 Kudos
1,149

Hi,

I am developing custom flexible workflow using SWDD_SCENARIO. This is a multi level approver workflow and one of the requirement is from Level 2, user at level 2 should review Sales order and have option to send to another team member e.g. level 2.5 in case of any queries. That another team member at level 2.5 will review questions raised by level 2, does necessary action and send back work item to Level 2.

Now Level 2 person will review again that sales order, if all good Approve and workflow should move to level 3. But in case he has any further queries, he will again click on button send to level 2.5. Again same process where person at level 2.5 will do the required action and send back to level 2. Which can be a loop in some cases, and if all good then loop will end when workflow goes to level 3.

Is there any standard flexible workflow present as reference or any documentation will help.

NOTE: All above is happening via Fiori "My Inbox" app.

Thanks & Regards,

Mayuresh

View Entire Topic
SBach
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello, you could model a outcome "2.5 rework" in the 2. level step with a step for exception handling and than "repeat step" as action. So after "2.5 rework" it comes back to "2". If another "2.5 rework" is required this could be repeated. And if it is approved it goes to "3".

mayurespatil11
Explorer

Thanks a lot Sebastian.

I tried via exception handling as suggested by you, it worked as per my requirement 🙂

mayurespatil11
Explorer
0 Kudos

Hello Sebastian,

One question related to similar functionality. The above loop I achieved using the approach you suggested.

By using same technique, I am trying to divert workflow step/level. Example, my requirement is to suppose at Level 5 work item, user should have buttons in My Inbox to go back to any previous levels. For this I created buttons like "Go to Level 1" , "Go to Level 2" etc and kept nature as negative. In Manage workflow app, inside exception handling kept navigations using "Required Action" option.

But problem is now suppose I am at level 5, I clicked on "Go to level 2", workflow goes to level 2 but again comes back to level 5 if I kept in Action result as "Continue". Tried with other options also. Basically in my case at level 5 when user goes to level 2, after that it should go in same sequence i.e. from level 2 to 3 and then 3 to 4 etc.

Can you please suggest how I can achieve this in custom flexible workflow.

dominik_ullrich
Advisor
Advisor

Hi Patil,

I do not see an easy solution for this. There are two possible solutions that come to my mind:

  1. Modify the instance programmatically.
    Use a callback, e.g. IF_SWF_FLEX_IFS_RUN_APPL_STEP~AFTER_COMPLETION_CALLBACK to programmatically modify the workflow instance and just add the future steps. The issue with that approach is that you'd probably have to hardcode or dynamically calculate what you want to happen in the future and by that loose the flexibility of defining what should happen by modelling the workflow instance. In addition the needed APIs are not yet well documented and it will probably require quite some trial and error to get it working.
  2. Restart and skip unneeded steps.
    You could set a property skip_to_level and trigger a restart of the workflow.
    Additionally you add a condition to your scenario "Skip if skip_to_level greater than ..." and assign it appropriately to the steps of your workflow that you might want to skip.
    Points to consider with this are:
    - If you use the workflow instance component to show the current state of the workflow you'll see the skipped steps. It probably depends on your use case if this is wanted, acceptable or unwanted.
    - If you want to ensure that the modeler doesn't forget to add the condition, you could implement the validation callback and check this there.

There might be additional solutions, but those two are the ones that I can think of at the moment.

Best regards, Dominik

mayurespatil11
Explorer
0 Kudos

Hi Dominik,

Thanks for the suggestions.

I tried with first approach, using method IF_SWF_FLEX_IFS_RUN_APPL_STEP~BEFORE_CREATION_CALLBACK. Here when I debugged I saw that next work item value is there in debug inside "MS_REFERENCE_STEP". When I change that in debug it worked as expected. But challenge here is I am not able to edit that IO_NEXT_ACTIVITY at runtime. Any hints/clue here?

For second approach which you suggested, I was not able to proceed since I did not found where I can write conditions to skip steps. If possible can you provide screenshot where step conditions are handled?

Thanks & Regards,

Mayuresh

mayurespatil11
Explorer
0 Kudos

Hi Dominik,

I got the solution you suggested in second approach i.e. handling using step conditions. Was successfully able to build diversion logic.

In IF_SWF_FLEX_IFS_RUN_APPL_STEP~AFTER_COMPLETION_CALLBACK, based on the diversion selected by user, I changed workflow container element. Based on this container element I kept condition inside "Manage Workflow" app for deciding which step should execute and which on should skip.

Thanks a lot your help here.

Regards,

Mayuresh

Georgeshaas08
Newcomer
0 Kudos

Hello, I tried via exception handling as suggested by you, it's ok for the first time, no problem the repeat step is ok.

But at the next step when y a push a second time on my button "Pour Avis" i have this error ==>

Georgeshaas08_0-1721283527241.png

With this scenario: 

Georgeshaas08_1-1721283553776.png 

STEP 1 ==> Issue "Pour avis" ==> ok

STEP "Pour Avis" ==> ok Return

STEP 1 ==> Issue ACCEPTED Validation OK

STEP 2 ==>  Issue "Pour avis" ==> KO NO Agent

It's the same with the standard Exception Rework when i executed this at the second time.

More than 1 exception in the same scenario give an error. Do you have any ideas ?

I have found this note :  "3229748 - Exception 'No users found for task' found for the sales document Flexible workflow" but it's not the user that created the Sales Order, i don't undertsand because it's ok the first timewith the agent rule and not a second time ==> the variable is filled with the SAP user.

Thank you for your return