---
parser: v2
author_name: Stephan Schluchter
author_profile: https://github.com/SchluchterStephan
auto_validation: true
time: 20
tags: [ tutorial>intermediate, software-product>sap-business-technology-platform , software-product>document-information-extraction, topic>artificial-intelligence, tutorial>free-tier]
primary_tag: software-product>sap-build-process-automation
slug: spa-dox-create-decision
canonical_url: https://developers.sap.com/tutorials/spa-dox-create-decision
---

# Create a Decision for Invoice Approval Process
<!-- description --> Create a decision to determine the approver of the invoices

## Prerequisites
 - You have [created the process](spa-dox-create-process), the form to trigger the process and the [automation](spa-dox-create-automation) to extract the invoice data

## You will learn
  - How to create a decision
  - How to make use of data types and how to create them
  - How to maintain a decision table and include it in the process flow

## Intro
   With a Decision you can include several policies, guidelines, business rules and so on into your process flow.

---

### Add a decision and create a data type


You will now add a decision to the flow of your process. With this you are able to include business logic.

1. Choose **+** following the automation **Extract Invoice Data**.
   
    ![Add decision](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/001a.png)

2. In the menu select **Decision**.

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

3. Click on **Blank Decision**.

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

4. In the **Create Decision** window:
    - Maintain the Name: **Determine Approver**,
    - Description: **Decision to determine who could approve the invoice**,
    - Choose **Create**.

    > The Identifier will be created automatically.

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

5. The **Determine Approver** Decision is now in the process and should open automatically in the **Decision Editor**. 
   
6. Navigate back to the **Get Invoice Details** process and save your process. 
   
7. Select the decision in the process, choose the three dots and select **Open Editor**.

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

8. You see a **Decision Diagram** showing the flow of the data within the Decision, and also the **Input and Output Parameters**.

9.  Add an input parameter with the following information:
    - Name: **Invoice Parameter**,
    - Description: **Invoice Details**,
    - Type: **Invoice**.

    > "Invoice" is the data type which has been created in the Automation and contains all relevant extracted data.

    ![Change Input](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/099a.png)

10. The data type for **Output** needs to be created. Therefore, select the **Folder Icon**. 
   
    ![Create new Data Type](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/007a.png)

11. Select **+** and choose **Create** > **Data Type**.

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

12. In the new pop-up window:
    - Define the Name: **Approver**,
    - Add a Description: **Including the approvers email address**,
    - Choose **Create**.

    > The Identifier will be created automatically.

    ![Name data type](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/008.png)

13. Create a **New Field**:
    - Maintain the **Name** `eMail`,
    - Choose the **Type** as `String`.

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

14. The new data type containing the email address of the approver is now created.

15. **Save** your work.

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

16. Go back to your **Determine Approver** Decision. Add an **Output Parameter**:
    - Name: **Approver Output**,
    - Description: **Invoice Approver**,
    - Select Type: the newly created data type **Approver**.

    ![Select new data type](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/098.png)

17. **Save** your work.


### Create a decision table


There are many ways to express a business rule, in this case you will create a decision table to determine the approver of the invoice based on certain criteria.

1. Open the **Rules** tab.

2. Choose **Add Rule**.

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

3. In the Create Rule window:
    - Set the Rule Name to **DT Determine Approver**,
    - Set the Description to **Decision Table to determine approver**,
    - Choose **Next Step**.

    ![Decision Table Name](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/015.png)

4. You will now configure the conditions:
    - Under **Vocabulary**, choose **Invoice Parameter**,
    - Select **Sender Name**,
    - Choose **Next Step** to configure the results.

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

5. You will now configure the results:
    - Under **Result Vocabulary**, select **Approver Output**,
    - Select **eMail**,
    - Select **Next Step** to review.

    ![Determine Approver Output](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/017.png)

6. Review and choose **Create** to create the rule.

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

7. If you need to edit the rule you just created, you may do so by selecting the pencil icon.

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

8. Define the attributes:
    - for **Sender Name**: `EXISTSIN['ABC Communication']`
    - for **eMail**: `'your SAP BTP user ID'`, e.g. `'diana.smith@mail.com'`.

    You can also make use of the value help, by pressing the space bar before maintaining the expression in the first column.

    This means, if the company name in the invoice is "ABC Communication", then the approval request will be sent to you. Otherwise, follow the next step.

    ![If Then](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/096a.png)

9. Select the first row and **Add Row** to **Insert After**. In case the **Sender Name** is defined as `EXISTSIN['Telecommunications']`, the approval request should be sent to any recipient you might want to choose. e.g. `'jane.doe@sap.com'`.

    > When inserting emails please do not forget the simple quotes otherwise you will end up with an error when you save the decision artifact.

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

10. **Save** your work. The decision table is ready.

    ![Decision ready](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-dox-create-decision/095a.png)



### Maintain input and output of the decision


Though the Decision is ready, you need to connect it to the data flow of your process and define which data should be the input and output here. Also, to get rid of this error marker.

1. Go back to the process and select the Decision.

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

    > You might not see entries in the Input. This is due to a bug. As a workaround, click on the three-vertical-dot and remove the decision. Add the decision again in the process.

    > Please refer to [the Knowledge Base Article](https://launchpad.support.sap.com/#/notes/3207153) for the complete workaround.

2. Define the Inputs:
    - Under **Bind Object**, click on `Select item` field
    - Select `Invoice details` to map the `Invoice Parameter`
  
    The input mapping is done.

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

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

3. Check the **Output**, it is **eMail**, as you have defined it in the decision itself.

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

4. **Save** your work.

You have now defined who should approve the invoice, based on the company name. Next, you will use the outcome of the business rule, the email address, as input for the approval.
