Improving the Sales Order Management 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.

Include the Decision Logic in the Process

Business Scenario

When approvers are determined automatically via decision logic in the process, this also needs to reflect in the following approval tasks. The recipients of the approval tasks should be based on the resulting process content / variables of the decision execution step.

You'll 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.

To learn more about how to include the decision logic in the process, follow this interactive 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.

Task 1: Include the Decision Logic in the Process

Steps

  1. Include the decision logic in the process.

    1. Choose Approval Form.

    2. Choose Clear to remove the existing value.

    3. Choose orderNumber.

    4. Choose Clear to remove the existing value.

    5. Choose Users.

    6. Choose Email.

    7. To view the required field, select the scroll bar to scroll down.

    8. Choose Groups.

    9. Choose UserGroup.

    10. You can modify your selection as needed.

    11. Choose Save.

Run the Process including Automation and Decision

Business Scenario

You have updated your business process with an automation and additional decision logic. Previously, you made sure that the process was running as expected. Now you need to re-validate because significant changes have been made. It is required to release and deploy the process again, and to the execute it for validation.

Run the business process with a full monitoring of the workflow instances and automation jobs.

To learn more about how to run the process including automation and decision, follow this tutorial.

Prerequisites

Before releasing and deploying your business process, please make sure you have completed the required Agent Management settings to execute the process with an automation.

Once you have taken care of the agent management settings, you can release and deploy the business process project to run the process.

Exercise Options

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

  1. Live Environment – by 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.

Task 1: Run the Process including Automation and Decision

Steps

  1. Release and deploy the business process.

    Use the following data:

    FieldValue
    StringW:\SalesOrdersDetails.xlsx

    1. Choose Release.

      1

    2. On the pop-up, choose Release.

    3. Choose Deploy.

    4. In the String field, enter W:\SalesOrdersDetails.xlsx.

    5. Choose Confirm.

    6. Choose Deploy.

  2. Run the business process.

    You will now run the process and learn how to monitor the process and work on the tasks. You have released and deployed the business process project.

    Use the following data:

    FieldValue
    Customer NameSAP SE
    Order NumberPO7918
    1. Choose Order Processing.

    2. Choose Order Processing Form.

    3. Choose Copy for the Form Link.

    4. Paste the form link into a new a browser window.

      When you open the form in the browser, you will see all the input fields you defined in the process trigger form.

    5. In the Customer Name field, enter SAP SE.

      You have to enter one of the order numbers from the excel file. Do not enter any random order number or else the automation will not give any results.

    6. In the Order Number field, enter PO7918.

    7. Choose Submit.

      After you have chosen the Submit button, you will be notified that the form has been successfully submitted.

      The workflow has been triggered and the approval process has started. You can now work on the tasks, monitor the process, and gain insights.

  3. Work on the tasks.

    Tasks are requests for users to participate in an approval or review process. These tasks appear in the My Inbox application shipped with SAP Build Process Automation. Users can claim, approve, and/or reject the task from their inbox.

    1. From the SAP Build Quick Start window, choose My Inbox.

      The provided tasks and forms might look different than this screenshot, depending on your configurations.

    2. Choose Approve.

    3. Choose Refresh.

    4. Note: all the tasks are listed on the left-hand side.

    5. Choose Submit.

  4. Monitor the process and automation.

    Monitoring business processes is one of the key aspects of successful automation. Using monitoring capabilities, you can proactively and consistently monitor process performance, identify any issues in the process, and take necessary actions to ensure business process continuity.

    SAP Build Process Automation provides different applications for monitoring and managing different process skills. The applications include Process and Workflow Instances, Automation Jobs, Acquired Events, and so on. These applications are available under the Monitor tab in Application Development studio.

    All deployed processes can be accessed by following ManageProcesses and Workflows application.

    1. Choose Monitor.

    2. Choose Process and Workflow Instances.

      In there, you will see all the running, erroneous, and suspended process instances. Use the filter bar to get a more customized view of the process instances based on different statuses such as running, completed, suspended, terminated, and so on.

      To explore different process monitoring options, go to the Instances list, and choose your new process instance that was just triggered via the start form.

    3. Choose Order Processing.

    4. Observe the process instance information which provides the context for the process. You can see actual process data flowing across different activities in the process, and the execution logs where you can trace how the entire process has been progressing. You can also see some basic runtime information for each activity such activity name, who started it, when was it completed, and so on.

      Note
      To view additional information, select the scroll bar to scroll down.
    5. To expand the Monitor pane, choose the arrow.

    6. Choose Automation Jobs.

    7. Choose the Warning icon (if applicable) to learn more about the Automation.

      You will see the automation ran successfully.

    8. Choose Process and Workflow Instances.

    9. Notice the process instance progresses further to the approval step in the business process.

  5. Gain visibility into the business process.

    1. Choose Lobby.

    2. Choose Sales Orders Management.

      Note
      To view additional information, select the scroll bar to scroll down.
    3. Choose Sales Order Visibility Scenario.

    4. Choose the Copy for Dashboard Link.

    5. Open the Visibility Scenario Dashboard by pasting the dashboard link in a browser window.

      The dashboard is there. The performance indicators are filling up. Depending on the time it has taken, there might be different results. Please now feel free to explore the details and discover what is included in each tile. You could even navigate into single instances.

Result

You have successfully completed the task run the process including automation and decision.

This concludes the tutorial.

Save progress to your learning plan by logging in or creating an account

Login or Register