Skip to Content
Author's profile photo Anjan Paul

Dynamic Multilevel approval Workflow using Block Step

Hi all,

   This document will show how you can create multilevel workflow using Block. Generally we are using Loop step to create Dynamic multilevel workflow. But Block step gives lot of advance feature like Deadline monitorin, Exception handling etc.

In this example User decision workitem will send to agent one by one i.e after first approver approve, second approver will get the User decision workitem.

So step by step as follows.

1.  Create a multiline container element for UserList.

/wp-content/uploads/2013/06/2_227469.jpg

2. Create a container element for Exit condition from block.

/wp-content/uploads/2013/06/3_227470.jpg

3. Create a Block step. Select ForEach as Block Type.

/wp-content/uploads/2013/06/1_227468.jpg

4. Use your multiline User list element in Dynamic Processing tab.  And give condition for exit from Block.

/wp-content/uploads/2013/06/16_227477.jpg

5. In the Block in Control tab Per Run Binding , bind the _LINE element with WF_PerForEach_Index element.

/wp-content/uploads/2013/06/19_227478.jpg

6. Now create a User Decision Step and put agent as &UserList[_UserList_line]&. It will send to User Decision step determined on perforeach loop index.

/wp-content/uploads/2013/06/21_227480.jpg

7. Add mail step for each outcome. And add Container Operation step in Reject outcome to exit from block if any user take decision to reject.

/wp-content/uploads/2013/06/29_227467.jpg

8. Final workflow design.

/wp-content/uploads/2013/06/a1_227929.jpg

9. Now Test thew workflow . Pass User name in the UserList.

A2.jpg

10. Now you can easily found that in this example User Decision will go first to BCUSER, then if BCUSER  approved it, it will go to ANJAN.

Its done.

Assigned Tags

      77 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Suresh Subramanian
      Suresh Subramanian

      Another good piece of work from Anjan.

      Excellent ! Thank you again, Anjan !!

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Thanks Suresh.:)

      Author's profile photo Hafizul Mollah
      Hafizul Mollah

      Hi Anjan,

      This is a very good documentation with step by step description and with relevant screenshot.

      Normally in this case we do use the Loop but we can do it more intelligently using this Block End Block steps.........very well documented thanks a lot for ur effort!!!!!

      Thanks again.......Well Done!!!!!!

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Than you Haziful. We are expecting some document from you also.

      Author's profile photo Pavan Chand Bhamidipati
      Pavan Chand Bhamidipati

      The use case , is not enough strong to prove what actually a block step can do, Well in my opinion you don't have to do all these to just send to approvers one by one, or parallel. This can be handled more easily with the decision step or Activity step  more easily. Just have a look at the below screen shot

      http://tinypic.com/r/igccag/5

      SAP Community Network Wiki - ABAP Development - Exception handling in Workflows

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

      Pavan, Thank for your valuable suggestion. Just want to share, whatever link you posted is not prove of that the approval step can be easily done one by one dynamically.

      The document you shared is complete different from my example. You shared the document -

      1 . How can you use dynamic parallel processing at one go, not one by one.

      2. How you can catch exception in block.

      Author's profile photo Pavan Chand Bhamidipati
      Pavan Chand Bhamidipati

      Anjan

      1 . How can you use dynamic parallel processing at one go, not one by one.

      Check the screen shot. click on the first hyper link, (tinypc link) did you ever try to check this tab what it can do?

      about the second hyper link as you said, yes, it does not have any relevance to the content what you posted, I just wanted to show how it can be used in other ways too.

      Because I saw in other thread you just referred this document, just to gain some thing tactically. you don't have to create a  document, which does not give enough information.I seriously feel that if any user who just goes through the SAP help  documentation, can easily do the same, what you just tried to showcase in this big document.

      Keep some quality in the information that you upload into SCN.

      Regards

      Pavan

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi Pavan,

         I think you need to recheck the link again.

         I am copying the description of Miscellaneous tab-

         Here it specified that "All processing instances are executed simultaneously."

         Its clearly specified it will generate all the workitem at once, not one by one.

        May be I am wrong, I am unaware of the functionality. Can you please share some link or some screenshot, how it is possible to generate workitem instance one by one.

        And another point, you wrote "just to gain some thing tactically".

        Can you please elaborate what is meant by it. If anyone want to create document, he can share his knowledge. And if the document is not relevant enough, for that Moderators are there to analyze it. If you feel this is not helpful, you can approach to moderators.

      Author's profile photo Pavan Chand Bhamidipati
      Pavan Chand Bhamidipati

      Anjan,

      Please keep your understanding with you. Thanks for such a nice document.

      Pavan

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi Pavan,

        We only share what we felt. You have every right to give comments of document created in SCN. May be Document creators are wrong or unaware of some functionality.   But before comment we should be modest enough and read the document thoroughly.

      I am also waiting for some link or documents from your valuable time to describe "how it is possible to generate workitem instance one by one"  . May  be I am unaware of this functionality.

      Author's profile photo Paul Bakker
      Paul Bakker

      Anjan,

      Thanks very much for posting this information. I have never heard of this functionality before! You may be able to do the same with a loop, but this approach certainly looks simpler and cleaner.

      Are there any known drawbacks? I wonder why I've never seen it used...

      cheers

      Paul

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Thanks Paul,

       

          I still not find any drawback, but found some advantage, if we want to skip series of activities based on condition, we can easily terminate the block. Also we can put deadline to complete the series of activities in block , which is not possible in loop.

      Author's profile photo Stéphane Bailleul
      Stéphane Bailleul

      Hi Paul and Anjan,

      Sorry for providing a feedback more than 4 years after...

      I have discovered this blog not long ago.. last week

      I like the functionality but may be not for a valiation because I think there is one drawback, it is not with the functionality during the conception but rather something missing for the maintenance.

      As the agent are being calcuated before and stored in a workflow container, if for one reason or another you have to recalculate the agent, well you won't be able to use the usual worfklow provided tool (SWI1_RULE ) that is why I like using rule directly within the dialog step.

      If I have missed something please inform me

      Regards

      Stephane

      Author's profile photo Rambabu Kunuku
      Rambabu Kunuku

      Hi Anjana,

      I think using this process, work item will be sent to all agents instead of one by one.

      after distribution of workitems, anyone can execute the workitem first.

      example: manager should approve only after supervis

      if this is the case how can we sequence the users here.

      Thanks.

      Rambabu

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi Rambabu,

         I think you need to check again.

      Author's profile photo Rambabu Kunuku
      Rambabu Kunuku

      Hi Anjan,

      i have checkd it, it is triggering all given users and any user can approve.

      Thanks

      Rambabu

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi Rambabu,

         What Block type you mentioned. Is it ForEach or Perforeach.

      Author's profile photo Rambabu Kunuku
      Rambabu Kunuku

      Hi Anjan, Please check.

      Snap2.jpgSnap1.jpg

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi Rambabu,

       

         In your screenshot you selected ParForEach in Block type. Please select ForEach only.

      Author's profile photo Rambabu Kunuku
      Rambabu Kunuku

      Great. Thanks Anjan

      Author's profile photo ajeet choudhary
      ajeet choudhary

      Hi Anjan,

      I have tried as per the description given by you but when i am testing workflow by filling user list container manually it is not showing any agent and giving msg 'No Selected Agent'.

      workflow is in process and not pending with anyone.

      Binding

      Capture.JPG

      Agent Expression in user decison step '&USERLIST[_USERLIST_LINE]&'.

      Could you please point out where i have errored?

      Regards

      Ajit

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

        Check the task, is it general task or not

      Author's profile photo ajeet choudhary
      ajeet choudhary

      hi Anjan,

      I have only user used decison step here and that uses generic task TS00008267 which again is general task.

      Author's profile photo ajeet choudhary
      ajeet choudhary

      Hi Anjan,

      Problem solved, actually i was passing userid without concatenating 'US' as a result workflow failling to determine approver.its working now and thanks for sharing document and it helps people like us.

      Regards

      Ajit

      Author's profile photo Former Member
      Former Member

      Hi Anjan,

      Thanks for this helpful post on using Block Step but i am having issues while using program exit to add users to a multiline container without hard coding the values.

      It would be very helpful if you could provide me with a tutorial or an example on how to implement it.

      Author's profile photo Former Member
      Former Member

      The issue have been resolve. I was not passing the expression as table[index] in the decision step of my workflow.

      Author's profile photo Murali Krishna
      Murali Krishna

      Dear Anjan...

      Thanks for sharing very useful information.

      Regards,

      Murali Krishna.

      Author's profile photo Former Member
      Former Member

      HI Anjan,

      Nice document.

      Is it possible to have this block step type where workitem goes to each level approver one by one but there could be multiple approvers at particular level . So it should go to all the approvers at a time at particular level and then to next level.

      Regards,

      Ibrahim

      Author's profile photo Kamal Jain
      Kamal Jain

      Hi Ibrahim,

      yes this is possible that WI will go to each level one by one and also you can add multiple approval at one level. WI will go to all and if any one completed then WI will be removed from inbox of all agents and Next level WI will be started.

      There 2 main things. Pls note.

      1. In block - block Type should be FOR EACH.

      2. Use deep structure, means table inside table for agent.

      Regards,

      Kamal Jain

      Author's profile photo Modak Gupta
      Modak Gupta

      I can vouch for what Kamal has said.....:-)

      Author's profile photo sudheer ganti
      sudheer ganti

      How is this possible?? Mine is custom delegated BO method. Here I can not declare parameter with deep structure. So How I should achieve this??

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

        Yes,as Kamal said, choosing FOR EACH will do that.

      Author's profile photo Former Member
      Former Member

      Author's profile photo Former Member
      Former Member

      Hi Anjan,

      Excellent Work!

      It works beautifully and fits my requirement 🙂

      I am facing one issue in the end block section/Ending the workflow.  As in my case, there are 3 levels of approvals.

      Incase of approvals, the work item goes from one level to another correctly.

      But in case of Reject at any of the levels the workflow should stop and come out of the workflow.

      However, it is still in the process stage and the workflow is not ended.

      Screenshot attached.

      Please provide your input.

      Regards

      Swamy

      Author's profile photo Shweta Huddar
      Shweta Huddar

      Hi Swamy,

       

      We have the same requirement, Can you please explain on how you created the deep structure inside the container.

      Thanks,

      Shweta.

      Author's profile photo Former Member
      Former Member

      Thanks Guyz. Will try this and let you know 🙂

      Author's profile photo Former Member
      Former Member

      Hi Anjan,

      I have a requirement where every user should be able to work on the decision simultaneously.

      Any Possible way to achieve that.

      Thanks.

      Author's profile photo Anil Kumar Chilukuri
      Anil Kumar Chilukuri

      Hi Linda,

      You can use Parforeach in a block to achieve the requirement.

      Thanks

      Author's profile photo Former Member
      Former Member

      Anil,

      Thanks. It sounds relevant. The requirement i have to implement is multiple levels of approval for ex Manager , submanagers etc and within every level dyanamic number of approvers, Reminder Approvals , Adhoc removal of the approvers.

      I am thinking to implement it with a subworkflow which will get everytime a list of approvers and using this block will do the approval process.

      Any suggestion regading adhoc removal of the approver ?

      Thanks

      Author's profile photo Vishesh Malik
      Vishesh Malik

      Hi Linda,

      If you are looking just for parallel processing of a Decision for which multiple approver have to take decision and based on their Decision further steps should be processed then you can use Fork.

      Regards,

      Vishesh

      Author's profile photo Former Member
      Former Member

      Vishesh,

      I could have used if the number of approvers are fixed. Its dyanamic.

      Thanks

      Author's profile photo Vijay K
      Vijay K

      Hi,

      What if the next level agent is based on the current actual agent?  May be we need to modify the agent table at the particular index inside the block?

      Author's profile photo Former Member
      Former Member

      Hi Anjan,

      I tried to use this with parforeach as i need parallel decision processing but if one user is Rejecting the decision the Workflow is setting itself in Error state ? I dont understand this behaviour.

      Please help further

      Thanks

      LS

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

        You can start a discussion sharin screenshot

      Author's profile photo Former Member
      Former Member

      Great Work Anjan, You are gem of Workflow:)

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Thanks Priyanka

      Author's profile photo Former Member
      Former Member

      Hello Anjan,

      This is very nice document. However i have one question if you can answer .

      1. If we send any work item to all the users at one go(parallel workflow) , will all approvers be able to approve that work item or workflow get completed even if one approver approvs the work item?

      I had posted the same question in another thread, as i am new with workflow

      Can we send Work ITem to more than one user and all should be able to approve the work item

      Thanks in advance

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

      Try same approch like Reject mentioned in this doeument. Take a container element and add a container operation to add 1 to that element . Then    in approve branch add another step of  condition to check that contaoner element = 1  or not .  In the yes branch you set ISEXIT = E adding another conatiner operation step.

      Your purpose  will ready

      Author's profile photo Former Member
      Former Member

      Dear Anjan ,

      Thanks i will work on as you suggested 🙂

      Regards

      Author's profile photo Former Member
      Former Member

      Hello Anjan,

      I have tried this and this is good.

      However i want to send one work item to all users , which i am able to do though parEach.

      However i have a requirement that each of the approver should be able to approve the task and unless all approver have not approved the work item, workflow should not be end?

      Can we acheive this for it?

      Thanks

      Author's profile photo Former Member
      Former Member

      please find screen shots /wp-content/uploads/2014/11/2_584739.jpg/wp-content/uploads/2014/11/3_584740.jpg/wp-content/uploads/2014/11/1_584753.jpg

      Author's profile photo Former Member
      Former Member

      hey ,

      My binding was incorrect , issue is resolved

      Thanks

      Author's profile photo Former Member
      Former Member

      Hi Anjan,

      Thanks for the Blog.

      I am very much new to Workflow. Started working on it only last week and this blog help me a lot. But I have one issue.

      I followed the steps mentioned, but the work item is created only for the first user. basically, I think it is not looping properly. Could you please let me know if there are some other steps which needs to be done apart from these steps.

      Thanks

      Vijay

      Author's profile photo Anand Babu V
      Anand Babu V

      Hi Anjan,

      Really nice document..

      Block type (FOR EACH)  and binding is fine.. only User decision step binding issue.

      FYI....I have created Multiple container name as USER not USERLIST.

      When I am trying it is not working as you explained.. Can u please clarify on the below things.

      In user decision I can map only Multiple container (USER) not like wat you have mapped multiple container with index  ( '&USERLIST[_USERLIST_LINE]&)

      If I map multiple container (USER)  in user decision (Expression) then workitem is going at a stretch to all users like parallel processing.

      if I map index number (_USER_LINE) in user decision (Expression) then nothing is doing  since it is the index number.

      How to map  multiple line with index like this (&USERLIST[_USERLIST_LINE]&)    in the user decision step

      Please guide on this...

      Thanks,

      Anand

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

      Can you please share screenshot of binding and workflow.

      Thanks,

      Anjan

      Author's profile photo Anand Babu V
      Anand Babu V

      Hi Anjan,

      Please find the screen shots below.

      Only doubt is how to bind in User decision (Multiple container with Index number)

      WF5.PNG

      WF1.PNG

      WF2.PNG

      WF3.PNG

      wf4.PNG

      Thanks,

      Anand

      Author's profile photo Anand Babu V
      Anand Babu V

      Hi Anjan,

      As I said before... If i bind USER in user decision step.. Workitem is going to all at the same time.

      If i bind _USER_LINE in user decision step.. noting is happening.. since _USER_LINE is holding the index number not the user name.

      Thanks,

      Anand

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      hi,

        please share the screenshot, how you bind the  _USER_LINE

      Thanks,

      Anjan

      Author's profile photo Anand Babu V
      Anand Babu V

      Hi Anjan,

      In the 3rd screen shot i am showing binding in the block and in the 5th screenshot I am binding User in the User decision step.. Please check above screenshots...

      I just want to know how to binding in User decision step...multiline container with Index...

      How you did the below step.. i cant able to do this.. multi container with index???

      In my case like this I am unable to do    ' &User[_UserList_line]&'

      If i typed manually in the binding step it is throwing error.

      6. Now create a User Decision Step and put agent as &UserList[_UserList_line]&. It will send to User Decision step determined on perforeach loop index.

      Thanks.

      Anand.

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

        Use  &User[_User_line]&   instead of &User[_UserList_line]&

      Author's profile photo Anand Babu V
      Anand Babu V

      Hi Anjan,

      Manually typed the binding  &User[_User_line]& in user decision working fine thank you!!!!

      Thanks,

      Anand

      Author's profile photo Former Member
      Former Member

      Hi Anjan,

      I am trying this example, however I am unable to activate the WF after using block step. Once I remove the block step, I can activate the WF. There are no errors while syntax check though. Any idea what I could be missing ?

      Thanks,

      Sid

      Author's profile photo Former Member
      Former Member

      Resolved. Very nice document Anjan.

      Author's profile photo Suresh M
      Suresh M

      Hi Anjan,

      Very nice document. Thanks for sharing.

      Author's profile photo Patrick Both
      Patrick Both

      Hello Anjan,

      absolutely fantastic document for a UserList Approval Workflow.

      I have a question and hope u can help me to solve it. I would like to build in a possibility to bounce the workflow to a Prior Approver in UserList (f.e. User 3 bounces his Decision so User 2 has to approve again).

      I tried it by adding a Containeroperation and set forEach_Index back to further number but that does not work. The index gets further in counting and the workflow ends.

      Do u have an idea how to solve that?

      Thanks,

      Patrick

       

      Author's profile photo Anjan Paul
      Anjan Paul
      Blog Post Author

      Hi,

       

      Now that will be quiet complex.  Please check like that way.  Trigger a Event from Block step after  Rejection. After that maintain at  Basic Data  of workflow -> Version   Dependant  ->  Events ->  Maintain the  Event with  Receiver Type  as  'Reevaluate Rule  of  Active  Workitems'.

       

      So that if anyone Reject, Workflow active workitem can be start from begining.  Try this and let us know .

       

      Author's profile photo ABDUL GAFFAR MOHAMMAD
      ABDUL GAFFAR MOHAMMAD

      Hi Anjan,

       

      Not getting "AGENT"

      Can you please let me know where exactly binding is missing ..?

       

      Thanks in advance.

      Regards,

      Abdul Gaffar M.

      Author's profile photo ABDUL GAFFAR MOHAMMAD
      ABDUL GAFFAR MOHAMMAD

      Hi all,

      Execution  user ID  prefixed with "US"

      Issue solved.

       

      Nice documentation Anjan  🙂

      Regards,

      Abdul Gaffar M.

      Author's profile photo sudheer ganti
      sudheer ganti

      Hi Anjan,

      Very Nice document. I struck here with deep structure. In my requirement it will be multiple as well as multi level workflow. At first approval there might be more than two and also at second level same like more than two. So I need to use UserList as Deep structure. But in my custom BO - ZBUS2081 I can not declare a parameter with deep structure to method. So hw shoud I resolve this??

      Author's profile photo sudheer ganti
      sudheer ganti

      Hi Anjan,

      As a simpler way here my requirement is in the UserList I will have one Position ID at each approval level instead of User IDs. For a Position ID I need to fetch all users assigned to it and I need to send work item to  all users assigned to that Position ID at each approval level. How can I achieve this in your Block Step way??

      Author's profile photo Sabarinathan C
      Sabarinathan C

      Hi Anjan ,

      I just followed the same step as per your suggestion but the issue is if the first person approves the request then it in workflow log it is displaying as pending with second person for approval. but the same request comes again to first person for approval.what might be the issue?

       

      Author's profile photo Former Member
      Former Member

      Hi Anjan,

      I get these warning message in my client’s system:

       

      This is my step and binding:

       

       

      The strange this is that I tried this out in my company’s sandbox system and it worked perfectly and didn’t give any warning message.

      Do you think these warning message mean anything? Am I missing some configuration anywhere?

      Thanks,

      Aditya.

      Author's profile photo reshma raman
      reshma raman

      Hello,

      I triggered workflow when status of claim notification (tcode iqs1 ) is in 'IN PROCESS'.

      I nedd workflow item with user decision button Approve/Reject and link to tcode iqs1. So that users can see claim notification and Approve/Reject with comments.

      Workflow need to triggered sequentially to multiple approvers.

      I have created user decision step with approve/reject. How to fetch agents in user decision step and trigger workflow sequentially to approvers. Kindly help.

       

      Thanks

      Author's profile photo ASHIS LOHIA
      ASHIS LOHIA

      Very useful document. Keep up the good work.

      Author's profile photo Sagnik Saha
      Sagnik Saha

      Hey Anjan,

       

      Beautiful documentation! ?

      Was in need of something like this and this popped up on my search hits.

       

      A quick question : I am in need of a updated functionality ; where until all the approvers in notification list approve the work item from their inbox ; it should revert the changes . So basically the reject part in this workflow suits the requirement ; but in the approve part I would need all approvers to approve the work item simultenously.

      The approvement should be a asynchronous mode ; unlike the generic functionality which puts the workflow as completed once any user approves the work item .

       

      Kindly your help if you happen to know of any such specifications.

       

      Thanks in Advance ?

      Author's profile photo Hobin Thomas
      Hobin Thomas

      Hi Anjan,

      It was a great document, which have used for my developments. But there is a query each there is some other changes on workflow the end condition in Loop Block is getting failed while rejection is happening. When the rejection happens it is flowing to level. So each time I have adjust the end condition of loop block. May this is strange behavior , have you faced anything like that.

      Regards

      Hobs

      Author's profile photo Siddartha Ramaraju
      Siddartha Ramaraju

      Hello author,

      Thanks for amazing blog. In my scenario if I have to execute an activity block only after the final approval ? How can I achieve this ? Please

       

      Thanks,

      Siddartha  Ramaraju