Skip to Content

Guided Procedure is a very effective tool for developing workflow processes in cross-applications environment. In enterprise business workflow processes we have multiple approval steps often where the process steps are dynamic and repetitive and the processor (approvers) are determined at runtime based on business conditions like requestor’s business unit or type of business transactions, etc. In this document let’s take an example where an employee of an organization raises a cash reimbursement request. Before the request is created in SAP ERP backend it needs to be approved by the manager of the employee. But based on the amount requested and the position of the employee the approval steps may increase or decrease and the approvers are selected dynamically based on the requestor’s HR hierarchy. E.g. if an employee of grade 1 raises a request of $1000 then 3 levels of manager’s approval is required as only a manager of grade 3 can approve a request of $1000. That means 3 levels of dynamic steps will be created at runtime (in a loop) and the processor of those actions will also be assigned at runtime based on the HR hierarchy of the employee.

Developing the User Interfaces
The user interfaces for the GP process are developed using Web Dynpro Java callable object implementing GP interface. To create a Web Dynpro Java callable object we need to implement a GP interface available in some standard DC provided by SAP. For more details how to create the Web Dynpro Java callable object please refer the following documents/weblogs:

  1. Implementing a Web Dynpro Callable Object which Implements the GP Interface
  2. Implementing a Web Dynpro Callable Object
  3. How to Get NW04s SP7 Guided Procedure APIs for Local Development
  4. Working with the APIs of CAF Guided Procedures: NWDI or Local Development?

Create two Web Dynpro components implementing the GP interface – one for requestor and another for approver. In both the Web Dynpro component define the GP callable object’s attribute structure as below:

Name Type Cardinality
CRR_Request Structure 0…1
amount Decimal 0…1
businessTransaction String 0…1
companyCode String 0…1
costCenter String 0…1
requestDate Date 0…1
username String 0…1
totalApprovalLevels Integer 0…1
currentApprovalLevel Integer 0…1
nextApprover String 0…1
ApproverList Structure 0…n
approvalLevel Integer 0…1
approverID String 0…1

These definitions should be present in the getDescription() method of both the Web Dynpro components. In the execute() method of the Interface Controller of the Request component you need not write any code except one line to hold the IGPExecutionContext object as below.
this.executionContext = executionContext;
In the complete() method populate the GP callable object’s output structure as defined in getDescription() method. Here the approval levels and the approvers’ user id are determined by calling a RFC in SAP ECC. In our example we take three approval levels. The approval levels and the approvers are populated in the ApproverList table of the GP callable object’s output structure. As we have three approval levels we have three rows in the ApproverList table. Also set the totalApprovalLevels, currentApprovalLevel and nextApprover attributes present in the CRR_Request structure. The currentApprovalLevel attribute value should be 0 as we are in the Request component i.e. no approval has been done. This attribute value should be incremented by 1 in the Approval component for each step. The nextApprover attribute value should be the first approver’s user id. And the totalApprovalLevels attribute value should be the total levels of approval required i.e. in this case 3.

In the next component i.e. the Approver component in the execute() method of the Interface controller read the GP callable object’s input structure as defined in getDescription() method. While reading the currentApprovalLevel attribute under CRR_Request increament its value by 1 and save it in the Web Dynpro context node attribute. Also read the ApproverList table and assign the nextApprover attribute value as well as below: wdContext.currentApprovalDetailsElement().setCurrentLevel(crrInitForm.getAttributeAsInt(“currentApprovalLevel”)+1);
Collection approvalItemList = crrInitForm.getStructures(“ApproverList”);
for (Iterator iter = approvalItemList.iterator(); iter.hasNext();)
{
IGPStructure approvalStruct = (IGPStructure) iter.next();
IWDNodeElement approvalElement = wdContext.nodeApprovalList().createElement();
approvalElement.setAttributeValue(“approvalLevel”, new Integer(approvalStruct.getAttributeAsInt(“approvalLevel”)));
approvalElement.setAttributeValue(“userID”, approvalStruct.getAttributeAsString(“approverID”));
wdContext.nodeApprovalList().addElement(approvalElement);
}
if(wdContext.currentApprovalDetailsElement().getCurrentLevel()<crrInitForm.getAttributeAsInt(“totalApprovalLevels”)) { wdContext.currentApprovalDetailsElement().setNextApprover((String)wdContext.nodeApprovalList().getElementAt(crrInitForm.getAttributeAsInt(“currentApprovalLevel”)+1).getAttributeValue(“userID”));
}

In the above code the nextApprover is picked from the ApproverList based on the currentApprovalLevel.

In the complete() method assign all the attribute values to the GP context attribute.

Developing the GP Process
For this process we need two Web Dynpro callable objects – one for the requestor and another for the approver. The approver Web Dynpro callable object will be used in a loop for multiple approval steps.

First create a sequential block consisting of the Web Dynpro callable object for the requestor under the process.

Then add a pre-conditional loop block consisting of the approval callable object in a loop body block. The pre-conditional loop block must have a decision action to control the looping.

The first action created under the loop block automatically becomes a decision action. We need a decision callable object to determine the looping step and number of loops executed. Decision actions can be either user executed or in background. For user executed decision action we can use the decision dialog. But as here we need to determine the looping step in background we’ll use a Business Logic callable object. Create a Business Logic callable object present under Process Control category as shown below:

image

Add two input parameters – currentLevel and totalLevels (type unsigned integer). These two variables will determine whether we need to loop or stop. totalLevels variable holds the total number of approval steps required and currentLevel variable holds the current approval level. Both the variables will be set from the initial (requestor) action and the currentLevel variable will be updated at each approval step.

image

Now in the next step create two resultstates for the Business Logic callable object. The resultstates’ names should be always continue and break (in small case). And these resultstates won’t be shown in the corresponding decision action. In the Expression specify the condition to break or continue in the loop block. Here in this example we’ll break when the current approval level exceeds the total level of approval required.

image

Add a Loop Body Block under the Precondition Loop Block. Select the Precondition Loop Block and select Loop Body Block from the drop-down and click on New as shown in the diagram below.

image

In the pop-up screen select Sequential Block and click Select.

image

Create an action under the Loop-Body block and add the Web Dynpro callable object for approval under it. Actions for rejections mails Also another sequential block can be added under the process after the Approval Block as Request Approved, which will be processed when the request is approved to send a notification or do posting at the backend. Now the process will look as below.

image

Parameter Mapping
Now we need to do the parameter grouping. Select the process as it’s the parent level to all the blocks and open the Parameters tab. First group the totalApprovalLevels attribute from the first callable object’s output structure to the Business Logic callable object’s (CheckLevel) input as below:

image

Next group the currentApprovalLevel attribute from the first callable object’s output structure to the Business Logic callable object’s input structure as below:

image

Note that the currentApprovalLevel attribute value of the Business Logic callable object should be equal to the Request callable object’s output structure’s attribute value for the first time. But while in the loop for approval action the value should be equal to the Approval callable object’s output structure’s attribute value. We’ll take care of that later.

Next group the output structure and input and output structure of the Request and Approval callable object together.

image

Now the parameter mapping at the process level will look as below:

image

Now we need to group the currentApprovalLevel attribute (from Approval CO to Business Logic CO). For that select the conditional loop block and open the parameters tab. Select currentApprovalLevel attribute of the Approval callable object’s output parameter and the same attribute of the Business Logic callable object’s input parameter and group them as below:

image

Dynamic Processor Assignment
The processor for the Approval component should be assigned dynamically as given by the nextApprover attribute value. Select loop body block (sequential block – Approver Request) under the conditional loop block and open the Roles tab. Check the checkbox “Filled From Context Parameter” beside Processor of Approver Request and a drop-down appears beside it. Select CRR_Request->nextApprover as below:

image

This will dynamically assign the nextApprover attribute value (which is changed to the approver at the next level in the Approver component) to the Approve Request action.
Now select the process and open the Roles tab. Select Processor of Create Request action as Initiator i.e. whoever starts the process will do the first action (create request). Also assign the built-in roles to the initiator or Administrator. Save and activate the process. This completes the process design. Now you can create an iview to start the process which can be integrated into the Enterprise Portal. Refer How To Present Your GP Processes To The End User for same.

Running The Process
As the process design and implementation is complete now we’ll run the process. Login to Enterprise Portal with the user to whom the iview is assigned. Click on the iview link to start the process. The Request component’s callable object (Web Dynpro view) is displayed. Enter the details as required.

image

The Check Approver button when clicked calls a RFC from SAP ECC and retrieves the approver details based on the amount and employee grade of the requestor as displayed in the table. Now the user clicks on Submit to send the request.

image

As shown above the next approver is displayed as the processor of the next action (first level approval) based on the approver list.

Now the first approver logs in to Enterprise Portal and find a task in his UWL as below:

image

When clicks on the UWL task it opens the GP process with the approver’s view.

image

Here the approver can approver or reject the request. If rejected a mail is sent to the requestor and the process stops. If approved then it goes to the next level of approval.

image

Similarly if the second approver approves the request then it goes to the third and final level.

image

Here all the approvers are assigned dynamically based on the data returned by the first/request action. And the Business Logic callable object determines the number of repetitions based on the current approval level (which is incremented every time in the approval action) and the total approval levels.

This way business processes having multiple dynamic steps and user assignment at run-time can be designed using Guided Procedure.

To report this post you need to login first.

65 Comments

You must be Logged on to comment or reply to a post.

  1. SAP User
    I was looking for similar kind of documents…

    One more thing I am new to GP, would you help me getting step by step guide in GP..Please….

    (0) 
  2. K V Srikanth
    Hi,
         Its a good one on GP. I would like to ask question regarding workflow in this entire process. Is the creation of workflow not required in this entire process to send mails or tasks to UWL of approvers? how was this achieved through workflow or something else?

    Thanks,
    Suresh.

    (0) 
    1. Dipankar Saha Post author
      Guided Procedure(GP) is used here instead of ABAP business workflow. ABAP business workflow is typically for designing workflows in a single system like ERP. But Guided Procedure is a Netweaver component for designing workflows in cross-system environment and the recommended technology for designing business processes in Netweaver based composite applications. You can develop any kind of workflows/business processes which spans across one or more systems using Guided Procedure, which you can develop in SAP Enterprise Portal. Guided procedure tasks can be configured to appear in the UWL.
      Refer the CAF tutorial center or SAP Help for more details on CAF and GP.

      Thanks,
      Dipankar

      (0) 
    1. Dipankar Saha Post author
      I don’t have specific knowledge about ESS/MSS applications but generally speaking Guided Procedure can be used to design any cross-system or heterogeneous and dynamic business processes. From GP you can execute a RFC/BAPI or a Web Service as background service call. Also you can call a Web Dynpro component view, SAP Transaction iview, Visual Composer iview or any Enterprise Portal iView as well as normal Web pages. If you explore the Guided Procedure design time and the tutorials available in SDN you can find out lots of possiblities using GP and CAF in developing composite applications.
      Thanks,
      Dipankar
      (0) 
  3. Mathan MP
    Hi Dipankar,
        We are trying out a similar kind of process wherein I need to check the result state. On one condition, I need to call Action1 and on another condition, need to call Action2. You have clearly told “The resultstates’ names should be always continue and break”. Once it encounters break, the flow stops. But my requirement should flow depending on two different values. Please tell me how can I achieve this.

    Regards,
    Mathan MP

    (0) 
    1. Dipankar Saha Post author
      Hi Mathan,
      For the decision action of the Conditional Loop Block the resultstate’s values must be continue and break. If you need to call different actions on different conditions inside the conditional loop block, you need to use another callable object after the business logic CO (inside the loop body block), where you can set the resultstates as required. Based on those resultstate values you can set the action target.
      Let me know if this clarifies your doubt.
      Thanks,
      Dipankar
      (0) 
  4. vaishali dhayalan
    Hi Dipankar,

    I am using VC iviews as callable objects in GP.
    How to perform multiple approvals using VC iviews?.. There is a piece of code u have added for WebDynpro Dev Comp?…But how is this possible in VC?

    Please Help.
    Thanks,
    Vaishali.

    (0) 
    1. Dipankar Saha Post author
      Hi Vaishali,
      This is bit difficult to achieve using Visual Composer only as in VC you can’t handle array of data and can’t loop into them. So to achieve this scenario using VC instead of Web Dynpro you need another callable object(background call e.g. EJB) where you can write the logic to find the next approver and pass that value to VC callable object.
      Thanks,
      Dipankar
      (0) 
      1. vaishali dhayalan
        Hi Dipankar,

        I have just started to learn GP. So, can you give me some more details or link as to how this can be achieved using EJB?

        What if the approval is not dynamic? Is it possible in VC if we have fixed number of approvers..For eg: 3 approvers… How to implement this scenario?

        Also,I will be obliged if you send a link to creating GP using VC iviews as callable objects?

        Thanks,
        Vaishali.

        (0) 
        1. Dipankar Saha Post author
          Hi Vaishali,
          You can refer the following document to create callable object for background execution in GP:
          Implementing a Callable Object for Background Execution

          If the approval is not dynamic then you can implement the scenario using the same number of approval callable objects as the number of approval steps under a sequential block only.

          Refer the following documents for creating VC iViews as callable object in Netweaver 7.0:
          Modeling Visual Composer iViews for Guided Procedures

          And the following document for the same in Netweaver CE 7.1:
          Exposing WD4VC Applications as Callable Objects

          Also you can refer the following documents for more details on composite application development :
          Composite Application Framework Tutorial Center
          Composite Application Development Cookbook

          Thanks,
          Dipankar

          (0) 
          1. vaishali dhayalan
            Hi Dipankar,

            Thanks a lot for your instance replies.

            I have tried out the exercise in the “Modeling Visual Composer iViews for Guided Procedures” link.

            But I did not understand “If the approval is not dynamic then you can implement the scenario using the same number of approval callable objects as the number of approval steps under a sequential block only” … Is there a example for this?…

            And two quick questions?
            1) If we have more number of approvers do we need to duplicate the GP process steps for each approver or its in the same GP thread itself.

            2)Which is the first view when approver logs into portal?

            (0) 
            1. Dipankar Saha Post author
              Hi Vaishali,
              If you know the number of approval steps at design time then you can define the same number of callable objects and corresponding actions in GP for the approval step. But if the approval steps are same in nature (only the approver changes, the view remains same) then better to use the conditional loop block by which you can have any number of approvals based on the runtime data.
              When the approver logs into the portal he/she will see the first view under the first role/workset/page as defined in pcd for the user role. This can be changed by portal content administration.

              Thanks,
              Dipankar

              (0) 
  5. Dmitry Geraskin
    Hi Dipankar,

    Very interesting blog, but is not possible to repeat design and test this process in GP without Java  experience because complete implementation code of Request and Approval WD components is not published.

    Can you attach WD components code or PCD transport with full process content to this blog?

    Best regards,
    Dmitry

    (0) 
  6. Madhusudhanan K
    I want to create a simple approve/reject functionality using GP. I have created 3 VC forms, one for initial input, 2nd for approve/reject. If the action taken is “Approve” then I display the 3rd form, if “Reject” then I need to display the 1st form again but with some comments. Since am new to GP kindly let me know how to achieve this using the options available in GP.

    Cheers
    Madhu

    (0) 
    1. Dipankar Saha Post author
      When you add the VC applications as callable objects in GP you’ll get the resultstate for the corresponding actions based on the resultstate buttons you have defined(approve, reject). Set the target of the differnt resultstate to the previous or next actions as required. This will control the flow of the process in runtime.

      thanks,
      Dipankar

      (0) 
  7. Mathan MP
    Hi Dipankar,
         I have created a process as you have mentioned in this blog.
    Firstly, I have a Web Dynpro callable object which has the list of approvers, current level and total level of approvers.
    Then, I have a precondition block wherein I have a business logic CO which compares the value of the current level to the value of total level.
    Thirdly, I have another Web Dynpro callable object that has input params current level, total level and Approver List structure. The output params are current level, total level and approver list structure

    Firstly, I have bound the current level and total level of the first web dynpro callable object and business logic CO

    Secondly, I have bound the current level, total level of Business Logic CO, Approvers Web Dynpro CO’s Input and Output.

    Also for the approving action, I have provided the current level approver in the fill from context param as role

    First time, it is being assigned to the first approver. Further, it is not getting assigned to the other users.

    Can you please tell me what could be the problem

    Regards,
    Mathan MP

    (0) 
  8. vaishali dhayalan
    Hi Dipankar,

    I have created an iview in VC 7.1 for approve or reject process. So I have included the result states approve and reject in the iview.

    I want to trigger a mail for approve/reject once the approver click on those buttons.

    I have created the mail templates in the GP Admin under the Maintain email Templates.

    I created the callable object of type WD4VC for the approve/reject screen.

    The steps for the callable object create are

    1.Basic Data
    2.Define Object
    3.Define Input
    4.Define Output
    5.Finish

    But to assign the email templates I need configuration parameters. There is no “Set Configuration” step for WD4VC callable object.

    I have just begun to learn GP and not much experienced with CE.

    Please can you let me know how this problem could be solved and execute this mail triggering scenario using VC iviews.

    Kindly suggest!.
    Requesting your help ASAP as I’m working on stringent deadlines.

    Thanks,
    Vaishali

    (0) 
    1. Dipankar Saha Post author
      Hi Vaishali,
      You need to create a new callable object of type Send Notification (under Misc category) after the approve/reject action. To this CO you need to assign the mail template and then set the resultstate target of the approve action to this notification CO. Also remember to configure the SMTP server for sending mail in Visual Admin.

      Thanks,
      Dipankar

      (0) 
  9. vaishali dhayalan
    Hi Dipankar,

    Thanks for your suggestion regarding the mail notification.

    I have an issue. The scenario is as follows:
    I have an order create screen.Where the user keys in all the order details and submits order.

    The next step is the approval step.
    But there is a catch here…. I have two users 1)End User 2)Sales Manager… Only the end user need to send the order for approval while the Sales manager need not send it for approval.

    Currently I have created a process with one block and all the action included ( order create and approval) …so the user keys in the order details and then the next action is the approval).All callable objects are VC iviews and of the types WD4VC.

    Please can you let me know how we can do the role based actions in the process??… Or any other suggestions..

    Thanks in advance.
    Vaishali

    (0) 
    1. Dipankar Saha Post author
      You can define two resultstate buttons in the order create CO as Create Order and Submit For Aproval and set the target of the first resultstate to the order create action directly (bypassing the approval step) and the second one to the approval action. In the VC model you can control the visibility of the Create Order(without approval) button by setting the condition in it’s property called Hidden, where you can check the user role from the UserData and return true or false (which makes the button hidden or visible).
      Please post these kind of queries in the CAF Forum

      Thanks,
      Dipankar  

      (0) 
  10. vaishali dhayalan
    Hi Dipankar,

    I am using WD4VC callable objects for my GP Process.

    I want to customize the task title Approval Process in GP.. But To be able to append a parameter, it must meet the following requirements:

    1)The parameter is required and is not a list.

    2)You cannot append an entire structure. You can select individual parameters from a structure that is also marked as required.

    But in the WD4VC CO we cannot change the field to “isRequired” …since we cannot make changes to the parameters in the WD4VC component.

    I have made the field to be appended to be “isRequired” in the VC iview but yet it does not become isRequired while i make a callable object of the VC iview.

    Please can you let me know where am I going wrong or what is the solution to solve this.

    Since VC 7.1 and CE is new. I did not get any answers for my posts in SDN in the CAF forum.

    Would be obliged if you can help me solve this problem.

    Thanks in advance,
    Vaishali.

    (0) 
  11. suresh A
    Hi Dipankar,

    Iam calling Webdynpro ABAP application as a callable Object. I dont see the parameters in the parameter list. I do have some input fields in my Webdynpro view. Is there anything that I have to do to make them appear. You were talking about getdescription() method in Java. Is there anything similar has to be done on ABAP side?

    Also I would like to trigger process from My Webdynpro application upon hitting a button.My application is already there in EP as an iView. Could you please suggest me how do I trigger the process from WebDynpro App?

    Thank You,
    Suresh.

    (0) 
      1. suresh A
        Hi Dipankar,

        Do you think if there is any work around to get the parameters from Webdynpro ABAP application in GP and also trigger a process from it?

        I have a Webdynpro ABAP application already to create some data in the data base. Before creating the data in Data base its needs to be approved by different departments.

        So, If I can’t pass any parameters from my application to other callable Object in GP, Iam just wondering how would I go further and achieve this functionality.

        Thank You.

        (0) 
        1. Dipankar Saha Post author
          Hi,
          Definitely you can instantiate a GP process from ABAP as explained in the following blog :

          Triggering a Guided Procedure (GP) process in CE7.1 from ABAP

          But as of now Web Dynpro ABAP doesn’t support output parameter to GP. What you may do as a workaround is you can store the output parameter value you need to pass from the WDA CO in the database table (from the WDA CO) with the process instance id as key and then read those values using a background CO after the WDA CO.

          Thanks,
          Dipankar

          (0) 
          1. suresh A
            Dipankar,

            Thanks a lot for your valuable inputs!!!

            In GP, is it possible to send a reminder to the user?

            For example, an email would  be sent to his/her UWL for approval. In case if they dont respond for two days I would like to send them an reminder email. Is that possible? If Iam able to send an email to the external ID that would be much better.

            Thank You,
            Suresh.

            (0) 
            1. Dipankar Saha Post author
              Hi,
              You can use due-date handling feature of GP blocks to send email to users using the Notification callable object.
              Thanks,
              Dipankar
              (0) 
          2. Bhavik Devisha
            Hi Dipankar,

            We do nto have capability in WebDynpro for ABAP to specify output parameters. Only one thing is, we can persist that data in table and then we can call RFC to retrieve output parameter values.

            Can you please share how to retrieve process ID value in ABAP code so that we can store the request/form data in table?

            Hope, this is not too much i am asking for.

            Thank you in advance.
            Bhavik

            (0) 
            1. Dipankar Saha Post author
              Hi,
              You can store the process id as a string parameter in a table in ABAP and can write and retrieve it by a RFC/Web Service.
              Thanks,
              Dipankar
              (0) 
              1. Bhavik Devisha
                Thanks for the response.

                I was looking for the code to retrive process ID in ABAP code so that I can store that value in table and later on retrive it in GP through RFC call.

                It would be very helpful if you share that code.

                Thanks,
                Bhavik

                (0) 
                1. Dipankar Saha Post author
                  Hi,
                  You need to call the GP web services to retrieve the process instance id in Web Dynpro ABAP CO as the GP APIs are only available in Java only.

                  Thanks,
                  Dipankar

                  (0) 
  12. suresh A
    Hi,

    If I need three different approvals, one approach is first one approves it goes to second approver and that is done it goes to third approver. If any one rejects it goes to initiator again to start the process again.

    Can I have parallel approval Process?

    For example, emails would be sent to all three at a time and when all three are done with approvals then I terminate my process.

    If yes, where do I make checks that if all three has approved?

    Thank You,
    Suresh.

    (0) 
    1. Dipankar Saha Post author
      Hi,
      As you have described the scenario it seems a sequential approval process only going to first approver initially, after approval to second and then to third approver. You can achieve this scenario using the sequential block only. And you can have two resultstates on each of the approval CO – approve and reject. The resultstate target for reject can be set to the initiator so that if rejected by any of the approver it goes back to the initiator action.
      Parallel block is used when you want the approvals in parallel i.e. all the three approvers will get the approval task simultaneously, but the process won’t move to the next level of action unless all three approvals are done (either approved or rejected).
      Thanks,
      Dipankar
      (0) 
      1. suresh A
        Hi,

        I tried those few things.

        I have 3 Visual approval CO’s in a parallel block. They all getting triggered at once. In the result states of every CO it only shows the list of actions that are there under that parallel block. Iam planning to perform different actions for Reject and approval. But those actions has to be under same parallel block. If I have them under same blcok then those actions are also getting called. I dont find any way to avoid particular actions in that parallel block.Is there any way that I can avoid?

        What I understand is ,If we go for parallel approvals all of them has to either Reject/approve to go to next level. There is no way I can trace who has approved and who has rejected and take actions accordingly.

        Is my understanding correct?

        Thank You,
        Suresh.

        (0) 
        1. Dipankar Saha Post author
          Hi,
          You can have more actions and corresponding COs after the approval action under the same parallel block which may be executed on different resultstates of different instances of approval actions. But the process flow will move to the next block after the parallel block only when all the actions under the parallel block are completed.

          Thanks,
          Dipankar

          (0) 
          1. suresh A
            Dipankar,

            I have tried different options. Iam not able to understand. I have 5 actions in a parallel blcok. I need 3 actions to triiger first and the other 2 I would like to call on different result states in the same parallel blcok.How would I restrict them not to trigger when the parallel block is called.what I have noticed is, it calls all the actions that are there in that parallel block. If I have those actions outside parallel block then those actions are not seen in the drop down list inside parallel block.

            Let me brief you my requirement, I guess you could be able to help me.

            I would like to create a record with some details in a custom table. Before I create, it has to go through the three different approvers. All the three approvers should get mail at same time. If any one rejects, mail will go to creator and based on the comments, creator will change and submit process again. After one rejection, if any approvers decision is still pending, I have to ignore them. I just have to send email to others saying the request is rejected by so and so person.If all three approvers approves, then  I will create entry in data base.

            Is that possible? Please Suggest.

            Thank You,
            Suresh.

            (0) 
            1. Dipankar Saha Post author
              Hi,
              If you used an action under a parallel block, then at runtime the process won’t move after the parallel block unless all the instances of the parallel block have the actions under them completed. So if you have added the the approval actions under the parallel block you have to wait until all the approval instances get completed. There are two options to achieve this – you can either wait for the approver users to manually open the individual tasks and complete them, otherwise when one of the action is rejected you can use the GP API to complete the remaining approval tasks automatically.
              Another point to remember is you need parallel dynamic block if you want to create multiple instances of the same action for different actions as explained in my blog. And ofcourse you don’t need 3 different actions under a parallel dynamic block if you want the same approval action to be used by different approvers. Just one action under the parallel dynamic block is enough. At runtime multiple instances of the same action will be created for each users of the user list assigned as processor by context parameter.

              Parallel block will just enable the single user assigned as processor to work on multiple actions present under the parallel block simultaneously.

              Thanks,
              Dipankar

              (0) 
              1. suresh A
                Hi Dipankar,

                Like you suggested I tried only one action with multiple instances. I tried in both PDB and Dynamic block. Both the cases when one user either rejects/approves the other instances are getting disappeared.Please suggest how to avoid that?

                Second thing is , If by using GP API’s if I complete the other two process manually after one rejection, would I be able to trace whether the approval was rejected or  approved in my next level of action after parallel block.

                In the parallel block, I have a visual approval CO which has two result states. When it is rejected I would like to call another CO where the initator will make changes and trigger process again. To do that, that CO has to be in parallel block itself. But if I keep that in parallel block that is getting triggered along with the action. Iam not able to avoid that. Iam very confused.

                Please suggest.

                Thank You,
                Suresh.

                (0) 
  13. Indranil Chakrabarty
    Hi Dipankar,
    I have a scenario where I need to send the GP to multiple user’s UWL in the second level.If any of them approves the process will go to the third level.I am able to send the process to the multiple user using Parallal Dynamic Block by adding the user at GP runtime.I want to send it to multiple user through coding.

    Please help
    Indranil

    (0) 
    1. Dipankar Saha Post author
      Hi,
      For your scenario you don’t need any special block. Instead of assigning a single user for the second level approval, assign a role/group containing multiple users. So the task will go to multiple users in that role simultaneously, but if any one of them approve/reject it, the task will go off from the worklist of other users as well.

      Thanks,
      Dipankar

      (0) 
  14. Indranil Chakrabarty
    Thanks Dipankar for the urgent reply,We have already provided the group name,ID instead of the user name but it is going one user only.Below I am giving the coding please check it.

    else if(wdContext.currentContextElement().getFormat().equalsIgnoreCase(“CDIT”))
         {
              wdComponentAPI.getMessageManager().reportSuccess(“Unique id of user is : “+ user.getUserFactory().getUserByLogonID(“test1”).getUniqueID());
              output.setAttributeValue(“O_Processor”,user.getUserFactory().getUserByLogonID(“test1”).getUniqueID());     

         }

    regards
    Indranil

    (0) 
    1. Dipankar Saha Post author
      If you use PDB I don’t think you can assign a group/role to each block. You need to provide an array of users in a multi-cardinality structure, for each of whom a parallel instance of the block will be created. And the process won’t move to the next level unless each one them completes their task. If you want to send the task to multiple users and then complete the task if any one of them completes it, use a sequential block and assign role/user group as the processor of the action.

      Thanks,
      Dipankar

      (0) 
  15. Sasi Reddy
    Hi Dipankar

    Excellent Blog… Is there anyway to assign multiple users to the same UWL Task/Process Action at runtime? I know that we can do it through group/role assignment. But in our case we cannot define groups since the users/approvers are more dynamic and we have a rules engine to determine the approvers. If we start creating groups, then we will end up with so many groups and this will become tedious to maintain in the future. Please let me know if you think of any better way.

    Appreciate your help in advance.

    Thanks
    Sasi

    (0) 
    1. Dipankar Saha Post author
      Hi,
      Maybe you can do that in the following way:
      Create a group or role in the UME with no users at design time and assign that group as the processor of the action. Now at runtime using the UME API assign the relevant users to that group/role when the process/task starts. Again unassign the users from the group/role when the process/task is completed.
      Thanks,
      Dipankar
      (0) 
  16. Amey Mogare
    Hi Dipankar,
    This is an excellent blog. It helped me a lot in building my process.

    I want to know what exactly happens when Approver clicks on “Reject” button. I can surely guess that in this case currentLevel wont be incremented and loop will continue as currentLevel<totalLevels. But from Approver callable object how do we determine when to call “TerminateProcessCO”??

    Can you please guide me on this?

    thanks and regards,
    Amey Mogare

    (0) 
    1. Dipankar Saha Post author
      Hi,
      That depends on the process design and the business requirement. If the requirement is such that rejection by any reveiewer means a total rejection, you can set the reject resultstate target to the TerminateProcessCO otherwise to the requestor action to change the request and again re-start the approval process. You need to simply set the resultstate to Reject inside the Reject action in webdynpro.

      Thanks,
      Dipankar

      (0) 
      1. Amey Mogare
        Thank you for valuable reply Dipanakar.

        OK I understood what would happen when user clicks “Reject” button. Would I add an output parameter to ApprovalCO named “ResultState” ?

        Eventually in my case if any one of approver rejects, request is re-routed to requester. But where does this “ResultState” would lie?

        And as the “TerminateProcess” action is right after the approval action (inside a sequential block), where do I determine whether to execute “RejectionMail” + “TerminateProcess” or not? Else after performing ApprovalAction above two actions would get executed.

        I hope I am asking correct questions.

        Thanks and regards,
        Amey Mogare

        (0) 
        1. Dipankar Saha Post author
          Hi,
          Resultstate is not an output parameter but a property of a callable object in GP which you can define while creating the CO (e.g. getDescription() method in Web Dynpro CO). Once the resultstates are defined those are available as parameters of the action to which this CO belongs to. For each resultstate you can set another action as a target. You can define multiple resultstates as well and can enable only one at runtime. In this case you can define two resultstates Approve and Reject and then set the correct resultstate at runtime based on business decisions.

          Thanks,
          Dipankar

          (0) 
  17. Amey Mogare
    Hi,
    Thank you for such a wonderful blog.

    Can you please comment on following problem where I have created a group statically without any users at design-time and I am assigning users to it programatically.

    I have created a group with no users at design time and I have assigned it to default roles in Processor of Approval action.

    But I’m facing two problems:-

    1. Before executing process, it is asking me to add atleast one user to this group. That is, it is not proceeding further to execute with empty group.

    2. And even if i assign one member to this group statically and then, I assign 2nd user programmatically, work item is ONLY going to 1st user which I have created at design-time.

    Again, Work list of dynamically added user is EMPTY. (Although this 2nd user is getting assigned correctly to this group. I have checked the Assigned Users of this group.)

    I am totally clueless about this. Pls suggest.

    Thanks and regards,
    Amey Mogare

    (0) 
    1. Dipankar Saha Post author
      Hi,
      You cannot modify the assigned role in the same CO at runtime. If you want to provide the same action for multiple users use Parallel Dynamic Block. But in that case each assigned users need to complete the step individually. Otherwise you can have a CO or a program before the execution of the CO where you want to add multiple assignments and then use the GP APIs to assign the individual users to the action.

      Thanks,
      Dipankar

      (0) 
      1. Amey Mogare
        Hi,
        Thank you for reply.

        I want to assign same action to multiple users and if anyone of them completes process moves forward.

        I read your following reply to one similar question :- 

        “Hi,
        Maybe you can do that in the following way:
        Create a group or role in the UME with no users at design time and assign that group as the processor of the action. Now at runtime using the UME API assign the relevant users to that group/role when the process/task starts. Again unassign the users from the group/role when the process/task is completed.
        Thanks,
        Dipankar “

        So i followed the same way. Following is the structure of my process:-

        –*1. Enter Data Block*
           —EnterDataAction
              —-RequestorCO

        –*2. ManagerApprovalBlock (preconditional loop block)*
            –CheckLevelAction (loop decision action)
               —CheckLevelCO

            –Approval block (loop body block)
              — ApprovalAction
                 — ApproverCO

        And in Roles tab of DataUpdateProcess, i have assigned default group for Processor of ApprovalAction as group = “APPR_GROUP”. This is the group I have created at design time.

        What is going wrong here?

        Thanks and regards,
        Amey Mogare

        (0) 
        1. Dipankar Saha Post author
          Hi,
          In which CO are you assigning the users to the group using UME API? GP internally determines the individual users from a group or role if assigned to an action. So you need to assign the users to the group before GP determines the individual users. Otherwise you can try using the GP APIs to assign individual users as the processor of the action from another CO before it.

          Thanks,
          Dipankar

          (0) 
          1. Amey Mogare
            Hi,
            I am assigning them to Group firstly inside my RequesterCO. Then after each approver level, i am keeping on adding new users to that group.

            But I have managed to assign users to the “Processor of approver” role at runtime using following code :-

            IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
                 
            IUser userJames = UMFactory.getUserFactory().getUserByLogonID(“James.bond”);

            IUser userSuperman = UMFactory.getUserFactory().getUserByLogonID(“Super.man”);

            IGPUserContext userContext1 = GPContextFactory.getContextManager().createUserContext(userJames);

            IGPUserContext userContext2 = GPContextFactory.getContextManager().createUserContext(userSuperman);
                 
            IGPProcessInstance prInstance = rtm.getProcessInstance(executionContext.getProcessId(),userContext1);

            IGPProcessInstance prInstance = rtm.getProcessInstance(executionContext.getProcessId(),userContext2);

                 
            rtm.addRuntimeDefinedUserToRole(prInstance, “Action_3”, userJames, userContext1);

            rtm.addRuntimeDefinedUserToRole(prInstance, “Action_3”, userSuperman, userContext2);

            This adds the James.bond and Super.man to role “Processor of ApprovalAction” that is “Action_3”.

            And Dipankar, I want to ask one more doubt…
            I am now creating these COs and Processes into DTR and I am not able to understand how will input parameter “currentApproverLevel” of Approver CO will receive incremented value after each iteration?? 

            Like at main process level:- we have mapped o_currentLevel of RequesterCO to i_currentLevel of CheckLevelCO

            And at Loop Block level:- we have mapped o_currentLevel of ApproverCO to i_currentLevel of CheckLevelCO

            But how do i ensure that i_currentLevel of ApproverCO will get incremented value each time??

            Thanks and regards,
            Amey Mogare

            (0) 
            1. Dipankar Saha Post author
              Hi,
              You need to increament the i_currentLevel value inside the approval callable object or by a background callable object just after that.

              Thanks,
              Dipankar

              (0) 
    2. Kiran Jakkaraju
      Amey,

      When you do dynamic user assignment, how do you able to remove the previous user assigned to the action.

      I am getting same problem , I am using the GP API and assigning the users at runtime. But COuld not able to remove the previous user from the action and the same action is getting assigned to all previous users.
      Thanks in advance.

      Regards
      Kiran

      (0) 
  18. Kiran Jakkaraju
    Hi Dipankar – first ofall, thanks for your articles and blogs on GP. Really it is motivating us to get into GP and BPM technologies.

    As we are doing dynamic approvals for our project, I am using Preconditional Loop block, where I have same screen with one action in the loop assigned to multiple users. When I assign the first user to the action, the same user will not get deleted/removed for subsequent levels.. as the process goes on for different levels, the users are assigned to the action are not getting removed and it is very difficult stop the previous users to see the next approver’s screen. I tried using GP API for remove assigned Processor , change Processor, remove user of the role etc options like in this forum link given below. I need your suggestion , how can I proceed further to remove the previous users.

    Thanks in advance for your suggestions.

    http://forums.sdn.sap.com/thread.jspa?forumID=162&threadID=1547456

    Regards
    Kiran

    (0) 
  19. Gajendra N Koka
    Hi Dipankar,

    Thank you for such a wonderful blog. Iam just wondering if this dynamic approvals is possible if I take the WebDynpro form as Requestor and Approver CO’s.

    If yes, please give me some hints on what I should be doing instead of the java code that you have in WebDynpro Java Callable Objects.

    Thank You,
    Gajendra.

    (0) 

Leave a Reply