Create and post incoming invoice in SAP workflow
Script overview
On the high level the script consists of the following actions.
- Open and log in to the SAP GUI desktop client.
- Find the MIRO transaction and enter the company code.
- Create an invoice and fill in all required fields.
- Post the invoice.
Let's explore these steps in detail.
Environment
- Windows OS that meets System Requirements
- SAP GUI v. 7.40-7.50 connected to some environment
- SAP GUI should be configured as described here
Script variables
| Variable name | Type | Description | Default value |
|---|---|---|---|
| ok_code | String | transaction code | MIRO |
| company_code | String | company code (needs to be set up before running the script) | |
| amount | String | amount of money in the invoice (needs to be set up before running the script) | |
| purchase_order | String | invoice purchase order (needs to be set up before running the script) | |
| login | Secret | SAP username (needs to be set up before running the script) | |
| password | Secret | SAP password (needs to be set up before running the script) | |
| quantity | String | quantity of items in the invoice (needs to be set up before running the script) | |
| current_date | DateTime | current date | |
| invoice_date | String | current date converted to string | |
| transaction_type | String | required to choose the right transcation type | Invoice |
| sap_path | String | path to the saplogon.exe (needs to be set up before running the script) | C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe |
Script workflow
Calculate current date
Description: The group calculates the current date and converts it to string.
- In the Constant Value action (reusable), bot pushes the current date to the
current_datevariable.

- In the Date Format action, bot converts the
current_datevariable into the String variableinvoice_datewith a specific format

Log in to SAP GUI
Description: The group opens SAP GUI and logs in to it.
tip
To reuse the group, make sure you have added the required SAP GUI credentials in Secrets Vault in WorkFusion Studio. If you add another Secret Vault entry, change the following variables:
login– SAP GUI username (Secrets Vault > Key)password– SAP GUI password (Secrets Vault > Value)
note
All Mouse clicks in SAP GUI are automated using the Inspector tool.
Log in to SAP GUI (reusable). In this group, bot launches SAP GUI using Launch Application, clicks on the Log on button (Click Mouse) in a specific window (Window), and then pastes credentials into the required fields (Enter Keystrokes).

Create and post incoming invoice
Description: The group allows to open the MIRO transaction for a specific company, fill in all required invoice fields, and post into the system.
- Create and post incoming invoice (reusable). The group of actions (Window, Click Mouse, Enter Keystrokes) opens the MIRO transaction for a specific company.

- The group of actions (Window, Enter Keystrokes, Click Muse, Wait) fills in all required invoice fields (Invoice date, amount, Purchase Order), clicks on the **Simulate **button, and waits for the Sumulate window to open.

- The Window and Click Mouse actions post the invoice into the SAP system.
