Skip to Content

Create a Decision

Create a decision to determine approvers who will be authorized to approve sales order based on complex rules
You will learn
  • Create & configure decision in the process
  • Create & configure data types
  • Model decision tables with rules expressions
ArchanaShuklaShukla ArchanaFebruary 3, 2023
Created by
celineaudinsap
November 20, 2022
Contributors
celineaudinsap
  • Step 1

    A decision consists of one or more policies. Each policy consists of a collection of rules. They are 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 have identified your rules, then define the data types relevant for designing the rules. This is an important step before you start modelling your decision because these data types will contain all necessary fields that will be needed to model the rule.

    In this section, you will create and configure a decision which will be used to determine the relevant approvers based on the sales order fields.

    1. In the process builder:

      • Choose + of the default conditional flow,
      • Select Decision then New Decision.
      001
    2. In the Create Decision window, do the following:

      • In the Name field enter Determine Approver,
      • In the Description field enter Rule to identify the potential approvers for sales order,
      • Choose Create button.
      002
    3. Now you have to model the decision. For that, choose the 3 dots next to Determine Approver decision, to open the menu and choose Open Editor.

      002
    4. 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.

      A Policy is a collection of rules to be executed in strict order, meaning that they will 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.

      002
    Log in to complete tutorial
  • Step 2

    A data type describes the data structure that can be used as an input and/or output parameter in an automation, a decision or processes. Data types enable you to formalize the data used as input/output parameters for 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 have 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 will create an Approver data object for decision output.

    1. Go back to the Overview tab, choose Create and select Data Type.

      002
    2. In the Create Data Type window, do the following:

      • In the Name field enter Approver,
      • In the Description field enter Approver details who will approve the order from supplier side,
      • Choose Create button.
      002
    3. In the Approver data type screen, choose New Field to add a new attribute to the data object.

      002
    4. In the Field Details section on the right, in the Name field enter Email. Keep the Type as 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 etc.

      002
    5. Similarly, add another attribute UserGroup of Type String to the data type.

      002
    6. Save changes.

      002
    Log in to complete tutorial
  • Step 3

    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.

    First, add this newly created data object as the decision output.

    1. Go back to Determine Approver decision tab.

      002
    2. In the Determine Approver section, you will select Add Input Parameter button and Add Output Parameter button to configure input and output parameters.

      002
    3. Configure Input Parameter:

      • In Name enter: Sales Order Input,
      • In Description enter: business rules input,
      • In Type choose: Sales Order.
      002
    4. Configure Output Parameter:

      • In Name enter: Approver Output,
      • In Description enter: business rules output,
      • In Type choose: Approver.
      002
    5. Save changes.

    6. Then you will create the actual decision-making parts that make the decision in the process. Under Determine approver, select Rules.

      002
    7. Select Add Rule.

      002
    8. In the Create Rule window:

      • Under Rule Type select Decision Table,
      • In the Rule Name enter Determine Approver,
      • In the Rule Description enter Rule to identify the potential approvers for sales order,
      • Choose Next Step button.
      002

      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.

    9. You will now configure the conditions. Under Vocabulary:

      • Select Sales Order Input data type,
      • From the dropdown, choose the inputs shippingCountry and orderAmount,
      • Choose Next Step button.
      002
    10. Configure the output or result of the decision table. Under Result Vocabulary:

      • Select Approver Output data type,
      • From the dropdown, choose outputs UserGroup and Email,
      • Choose Next Step button.
      002
    11. Review and choose Create button to create the rule.

      002

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

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

      002
    13. Click in the first field (first column)

      002
    14. Type EXISTSIN, and choose exists in from Array Operators.

      002
    15. Continue typing, and write this expression: EXISTSIN [‘United Kingdom’ , ‘India’ , ‘Germany’]. After you have finished, press Enter key or click outside the input field to confirm.

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

      002

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

    16. Choose the input field of Order Amount column (second column of the decision table) and enter <= 100000.

      002
    17. Similarly, enter the following expressions for the respective result column (or Then section):

      • Under UserGroup enter: 'SO_APPROVER'
      • Under Email enter your email such as jane.doe@sap.com

      Do not forget to put single-quote (’) for string type values

      002

      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.

      So, 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 value is greater than 100000, the second row will return; and for any other combination that does not match the rows – an empty result will be returned.
    18. To add a new row to the decision table, do the following:

      • Choose the check-box of the first row,
      • Choose Add Row,
      • From the dropdown options, select Insert After.
      002
    19. Similarly, enter the following values for the new row:

      Condition Column Value
      Shipping Country
      Order Amount >100000
      Action Column Value
      UserGroup 'SO_MGMNT'
      Email john.doe@sap.com
      002
    20. Choose Save button.

      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

    Log in to complete tutorial
  • Step 4

    After you have 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. Open the process builder, choose Determine Approver decision and do the following. Choose Inputs tab.

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

      002
    2. Map the following decision table input with the process content:

      Decision Input Field Process Content
      expectedDeliveryDate selectedOrder > expectedDeliveryDate
      orderAmount selectedOrder > orderAmount
      orderDate selectedOrder > orderDate
      orderNumber selectedOrder > orderNumber
      orderStatus selectedOrder > orderStatus
      shippingCountry selectedOrder > shippingCountry
      002
    3. Save the process.

      002

      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.

    What are different components of Decisions:

    Log in to complete tutorial
  • Step 5
    1. You will now adapt the business process one last time to fully automate your approver selection by matching the recipients of the approval form to the one returned from the decision table.

    2. Select Approval form:

      • Match orderNumber from Get Order Details automation in the Subject,
      • Under Recipients > Users select Email from Determine approver decision,
      • Under Recipients > Groups select UserGroup from Determine approver decision.

      You can modify your selection as needed.

      002

    Log in to complete tutorial
Back to top