Improving the Process with Decision Logic

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Create and configure decision logic in the process
  • Update an existing process

Introduction: Improving the Process with Decision Logic

Definitions and Rules for Improving the Process with Decision Logic

Now you will learn how to create and configure a decision. A decision consists of one or more policies. Each policy consists of a collection of rules. These rules are used to automate the decision-making parts of a business process. After you create a decision (policy), you define your business logic by adding rules to the policy or policies.

Create and Configure Decision Logic in the Process

Business Scenario

Business processes usually require different approvers depending on the actual data in the process. Approvers shouldn't be hard coded into approval steps, but should be calculated dynamically with each process run. Also, in some situations, an actual approval by a human might not even be required, but the process should be approved automatically. Decisions and decision logic are perfectly suited to handle these kinds of situations. In the following, you'll create decision logic that will approve a sales order automatically when its sales order amount is below a certain threshold.

Create a decision to determine approvers who will be authorized to approve sales order based on complex rules.

To learn more about how to create and configure decision logic in the process, follow this tutorial.

Exercise Options

To carry out this exercise, you can choose from the following options:

  1. Live Environment – Using the instructions provided below, you can perform the steps in your SAP BTP account.
  2. Platform Simulation – Follow the step-by-step instructions within the simulation.
  3. Side-by-side – Follow the step-by-step instructions within the simulation and perform the steps in your SAP BTP account simultaneously.
Note
We strongly recommend to perform the steps in the live environment.

To add a decision, first identify the set of rules to consider in the decision-making process.

Then define the data types relevant for designing the rules. Data types will contain all the necessary fields that will be needed to model the rule. For example, if a design rule says "Sales Order Amount greater than 100000", then set the Approver e-mail as lorin@domain.com. Then, the data types are Sales Order with Amountfield, and Approver withEmailfield.

Task 1: Add a Decision to the Process

Steps

  1. Add a decision to the process.

    A decision consists of one or more policies. Each policy consists of a collection of rules. They're used to automate the decision-making parts of a business process. After you create a decision, define your business logic by adding rules to the policy. There are two types of rules:

    • Decision Table Rule: A decision table is a collection of input and output rule expressions in a tabular representation.
    • Text Rule: A text rule is the collection of rule expressions in a simple if-then format.

    To add a decision, you must first identify the set of rules that you need to add to the decision-making process. Once you've identified your rules, then define the data types relevant for designing the rules. This is an important step before you start modeling your decision, because these data types will contain all necessary fields that will be needed to model the rule.

    Use the following data:

    FieldValue
    NameDetermine Approver
    DescriptionRule to identify the potential approvers for sales order
    1. Choose Add.

    2. Choose DecisionNew Decision.

    3. In the Name field, enter Determine Approver.

    4. In the Description field, enter Rule to identify the potential approvers for sales order.

    5. Choose Create.

  2. Create the data types.

    Use the following data:

    FieldValue
    NameApprover
    DescriptionApprover details who will approve the order from supplier side

    A policy is a collection of rules to be executed in strict order, meaning that they'll run in the order in which they are added to the policy, and only the results of the last rule execution will be given as the final output of the decision.

    A data type describes the data structure that can be used as an input and/or output parameter in an automation, a decision, or steps, activities, skills processes, scenarios, triggers, or notifiers. Data types facilitate the manipulation and validation of data.

    You can create a data type manually, but some data types can also be created automatically when SDK packages or pre-packaged scenarios are imported, or after running an automation.

    Now, you've to map the Input and Output of the decision to the actual data object available with the process. In this section, you will use Sales Order as the Input data object and Approver as the Output data object. While the Sales Order was already created in the automation step, you'll create an Approver data object for decision output.

    In the following steps, you will create data types.

    1. Choose More.

    2. Choose Open Editor.

      A decision editor opens. You can see the decision diagram on the left panel and configuration option for Input and Output on the right panel. Notice the default policy that is pre-created with the decision.

      A decision diagram is a flow chart that describes the execution flow of the decision logic from the input to the output. Using a decision diagram, you can view the input, output, policies of a decision, and the rules of the policies. You can also access each component of a decision, like a policy or a rule, via the decision diagram itself.

    3. Choose Overview.

    4. Open the Create list.

    5. Select Data Type.

    6. In the Name field, enter Approver.

    7. In the Description field, enter Approver details who will approve the order from supplier side.

    8. Choose Create.

  3. Add attributes to the data types.

    Use the following data:

    FieldValue
    First field
    NameEmail
    TypeString
    Second field
    NameUserGroup
    TypeString

    1. To add new attributes to the data object, choose New Field.

    2. In the Name field, enter Email.

    3. In the Field Details area, as Type, choose String.

      You can choose the Type dropdown list to see the different kind of data types that are supported like Number, Password, Date, Time, Boolean, and so on.

    4. Choose New Field again.

    5. In the Name field, enter UserGroup.

    6. In the Field Details area, as Type, choose String.

    7. Choose Save.

    8. This is the result:

  4. Configure the decision.

    After the data types are created, you will now configure the decision:

    • With Input and Output data types.
    • Create decision table rule to the business policy.

    In the following steps, you'll configure the decision.

    Use the following data:

    FieldValue
    Name (Input)Sales Order Input
    Description (Input)business rules input
    Type (Input)Sales Order
    Name (Output)Approver Output
    Description (Output)business rules output
    Type (Output)Approver
    1. Choose the Determine Approver tab.

    2. Choose Add Input Parameter.

    3. Choose Add Output Parameter.

    4. In the Name field of the Input Parameters, enter Sales Order Input.

    5. In the Description field, enter business rules input.

    6. Open the Type list.

    7. Select Sales Order.

    8. In the Name field of the Output Parameters, enter Approver Output.

    9. In the Description field, enter business rules output.

    10. Open the Type list.

    11. Select Approver.

    12. Choose Save.

  5. Add a rule.

    Use the following data:

    FieldValue
    TypeDecision Table
    Rule NameDetermine Approver
    Rule DescriptionRule to identify the potential approvers for sales order

    1. Choose Rules.

    2. Choose Add Rule.

    3. On the Rule Details screen, choose Decision Table.

    4. In the Rule Name field, enter Determine Approver.

    5. In the Rule Description field, enter Rule to identify the potential approvers for sales order.

    6. Choose Next Step.

      A decision table is a tabular representation of the rule with If and Then header and row columns. If-header columns contain the expressions, which are evaluated, and Then-header columns contain the result structure that will be returned after the decision is run.

    7. To expand the Sales_Order_Input Items pane, choose the arrow.

    8. Select orderAmount.

    9. Select shippingCountry.

    10. Choose Next Step.

    11. To expand the Result Vocabulary items pane, choose the arrow.

    12. Select Approver_Output.

    13. To expand the Approver_Output Items pane, choose the arrow.

    14. Select Email.

    15. Select UserGroup.

    16. Choose Next Step.

  6. Create the rule in the next step.

    In the newly created Decision Table, add values to condition and result columns.

    1. To create the rule, choose Create.

      You can use the Settings option to easily define these If and Then header expressions with inline suggestions or free-flow typing.

      Use the following data:

      FieldValue
      Conditionlower than 100000 (with the mathematical sign, see screenshot)
      ExpressionEXISTSIN [‘United Kingdom’ , ‘India’ , ‘Germany’]
      UserGroup'SO_APPROVER'
    2. Choose Sales_Order_Input.orderAmount.

    3. In the Condition field, enter "lower than 100000", see screenshot below.

    4. Choose Sales_Order_Input.shippingCountry.

    5. In the Expression field, enter EXISTSIN [‘United Kingdom’ , ‘India’ , ‘Germany’].

      You can either type in the entire expression as free-flow, or use the context help to write the expression.

      Note

      Remember that for all String type data object attributes, you must add a single quote (’) before and after the text.

    6. Under Email, enter your email, such as jane.doe@sap.com.

    7. Choose UserGroup.

    8. In the UserGroup field, enter 'SO_APPROVER'.

      User Group is a role collection or group created in the BTP cockpit or in your respective user management system. These groups have users who are responsible for certain jobs. The advantage of using groups is that you can add/remove users from these groups without the need to change the decision.

      To ensure that the decision table rule returns definite output for all kinds of sales orders, add one more row to the decision table to return the list of approvers who can approve the sales order for value "greater than 100000".

      For example, for all sales orders coming from India, Germany, or the United Kingdom (the defined shipping countries), which have a value smaller or equal than 100,000, the first row will run. For all other sales orders whose values are greater than 100000, the second row will return. And for any other combination that doesn't match the rows, an empty result will be returned.

    9. To expand the Add Row Items pane, choose the arrow.

    10. Select Insert After.

    11. Choose Sales_Order_Input.orderAmount.

    12. In the Condition field, enter greater than 100000, see screenshot below.

    13. Under Email, enter your email, such as jane.doe@sap.com.

    14. Choose UserGroup.

    15. In the UserGroup field, enter 'SO_MGMNT'.

    16. Choose Save.

      Save will both save and activate the decision table. If there are any validation issues in the decision table, then Save will not happen and the errors will be shown in the Design Console.

  7. Configure a decision in the process builder.

    After you've created and configured the decision, next you have to map the input fields of the decision with the actual process content fields from the process builder.

    1. Choose *Order Processing.

      You might not see entries in the Input, please refer to the Knowledge Base Article for the complete workaround.

    2. Choose Determine Approver.

    3. Choose expectedDeliveryDate.

    4. Choose expectedDeliveryDate.

    5. Choose orderAmount.

    6. Choose orderAmount.

    7. Choose orderDate.

    8. Choose orderDate.

    9. Choose orderNumber.

    10. Choose orderNumber.

    11. Choose orderStatus.

    12. Choose orderStatus.

    13. Choose shippingCountry.

    14. Choose shippingCountry.

    15. Choose Save.

      You might see an error symbol on your decision. This is because the outbound connection from the decision is still dangling and not connected to any activity. You may connect it to the end activity.

    16. This is the result:

    17. Back on the process:

Result

You have successfully created and configured decision logic in the process.

This concludes the tutorial.

Make Updates to the Process

Let’s adapt the business process one last time to fully automate your approver selection by matching the recipient of the approval form to the one returned from the decision table. You can modify your selection as needed.

Log in to track your progress & complete quizzes