---
parser: v2
author_name: Shukla Archana
author_profile: https://github.com/ArchanaShukla
auto_validation: true
time: 20
tags: [ tutorial>intermediate, software-product>sap-business-technology-platform, tutorial>free-tier ]
primary_tag: software-product>sap-build-process-automation
slug: spa-create-decision
canonical_url: https://developers.sap.com/tutorials/spa-create-decision
---

# Create a Decision
<!-- description --> Create a decision to determine approvers who will be authorized to approve sales order based on complex rules

## Prerequisites
 - [Create an Automation to Extract Data](spa-create-automation)

## You will learn
 - How to create & configure decision in the process
 - How to create & configure data types
 - How to model decision tables with rules expressions

---

### Add a Decision to the Process

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

    ![001](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/001.png)

2. Select **Decision**.

    ![001b](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/001b.png)

3. Click on **Blank Decision**.

    ![001c](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/001c.png)

4. 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/002.png)

5. 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/003.png)

6. 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/004.png)


### Create Data Types


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. Click on the **Open Project Content** icon as below.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/005.png)

2. Select **+**. Choose **Create** > **Data Type**.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/005b.png)

3. 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/006.png)

4. In the **Approver** data type screen, choose **New Field** to add a new attribute to the data object.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/007.png)

5. 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/008.png)

6. Similarly, add another attribute `UserGroup` of **Type** **String** to the data type.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/009.png)

7. **Save** changes.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/010.png)


### Configure 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.

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

1. Go back to **Determine Approver** decision tab.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/011.png)

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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/012.png)

3. Configure Input Parameter:
    - In Name enter: **Sales Order Input**,
    - In Description enter: **Business rules input**,
    - In Type choose: **Sales Order**.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/013.png)

4. Configure Output Parameter:
    - In Name enter: **Approver Output**,
    - In Description enter: **Business rules output**,
    - In Type choose: **Approver**.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/014.png)

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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/015.png)

7. Select **Add Rule**.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/016.png)

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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/017.png)

    > 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/018.png)

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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/019.png)

11. Review and choose **Create** button to create the rule.

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/020.png)

    > 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/021.png)

13. Click in the first field (first column)

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/022.png)

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

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/023.png)

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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/024.png)

    > 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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/025.png)

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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/026.png)

    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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/027.png)

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'`|

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

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/028.png)


### Configure Decision in Process Builder


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 
    - Choose **Inputs** tab
    - Map the **Sales Order Input** choosing the `SelectedOrder` with **Bind Object** option  

    > You might not see entries in the Input, please refer to [the Knowledge Base Article](https://launchpad.support.sap.com/#/notes/3207153) for the complete workaround.


    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/030.png)

    > You can choose to map the Single Properties from the selected order 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` |


2. **Save** the process.    

    ![002](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/031.png)

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



### Update the Process

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](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-create-decision/032.png)

3. Save your work.

---
