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 in the process
  • Create reusable data types
  • Model decision tables with rule expressions

Creating and Configuring a Decision

Yay! You have done it. You have added a condition criterion to route the process flow for either an auto-approval or one-level approval. Now imagine what happens if you have multiple decision criteria in your process that are based on complex policies or rules.

In this lesson, you will create a decision to determine approvers who will be authorized to approve a sales order based on complex rules like sales order amount, or shipping country etc.

Including Policies and Business Rules in the Process

SAP Process Automation provides no-code Decision capability through which you can model and manage complex business logic in a well-formed structure that is easy to maintain. It helps businesses to segregate decision logic from application code to improve agility and empower business users to make changes in the decision without the need to consult IT expert or redevelop the application. It provides a no-code platform to easily develop and manage rules without the need to know any technical language.

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.

There are two types of rules:

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

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 get a quick overview of 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, directly from the decision diagram.

To Create and Configure a Decision

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.

For Example: If you have design a rule say Sales Order Amount > 100000 then set Approver Email as lorin@domain.com.Then data types are Sales Order with Amountfield and Approverwith Emailfield.

With all the relevant information you now have, let us start modelling the business rules:

Steps

  1. Add the decision to your process.

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

    Double click to open the decision editor. You can see the decision diagram in the left panel and configuration option of Input and Output in the right panel. Notice the Default policy that is pre-created with the decision.

    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.

    Now, you have to map the Input and Output of the decision to the actual data object available with the process. In this unit, we 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, let us create an Approver data object for decision output.

  2. Go back to the project overview page and create a new data object and give it a name and description.

  3. Under New Field, add Email and UserGroup fields, both of which are String type.

  4. Add this newly created data object as the decision output.

  5. Now you will create the actual decision-making parts that make the decision in the process. Go into the Default Policy panel, then create a Decision Table and give it a name and description.

    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.

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

  7. Select Determine Approver Input in the Vocabulary

    As you start typing in the Condition Expression box, you will get in-place suggestions with the list of decision Vocabulary, Operators and Functions.

  8. Next, select shippingCountry option from the drop-down menu. The final expression should look like Determine Approver Input.shippingCountry

    1. Also define the Label as Shipping Country; this will be what business users see when they are editing the decision rows.

    2. Similarly, add another condition expression as Determine ApproverInput.orderAmount with the Label as Order Amount.

  9. It’s time for final setting: selecting the Determine Approver Output data object as the decision Result and click Apply to create decision table structure.

    This completes defining the decision table structure where a decision table is created with two header columns based on Sales Order fields and two result columns based on Approver, as defined in the decision table settings dialog:

  10. After setting the decision table structure – which defines the If and Then expressions – let’s fill the decision table rows with values. The rule is then evaluated as: f Shipping Country = ‘Germany’ then return Email = ‘someuser@domain.com’ and UserGroup = ‘DL_MANAGERS’

    1. You have previously designed condition expressions, so click on the row cell for the first column and start writing the expression (you can also copy paste the expression below if you want).

      EXISTSIN ['United Kingdom' , 'India' , 'Germany']

    2. Similarly, enter the values for the rest of the columns of the decision:

      • IN [100000 .. 300000]
      • 'SO_APPROVER'
      • '<your email address>' for example: 'someone@any.com'

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

      UserGroup 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.

    3. 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 300000.

      So, for example, for all sales orders coming from India, Germany, or the United Kingdom (the defined shipping countries) which have a value between 100,000 and 300,000 – the first row will run. For all other sales orders, whose value is greater than 300000, the second row will return; and for any other combination that does not match the rows – an empty result will be returned.

      You have finished modelling the decision table – remember to save it! Next, you must map the decision table input fields with the actual process content fields from the process builder.

Result

You are now prepared to add more decisions to your process to meet your specific requirements.

To Update 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.

To Release, Deploy and Run the Business Process Project With Rule Expressions

After you have made updates to the process, the last step is to test the changes. As explained in the previous unit, repeat the steps of first releasing and then deploying the business process project.

Fill the Order Processing Form and submit for approval. Then observe the execution log and context of the process where you can trace the decision table execution.

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