Create and post incoming invoice in SAP
Problem statement
Many companies use ERP systems to manage their financials, logistics, human resources, and so on. SAP is one of the most known ERP systems in the world. The larger the company is, the greater is the need to use some system to manage company resources. Working in SAP takes a lot of time on different work levels. Thus, automation of this job will save time to focus on other tasks.
Existing manual process
Usually, to create and post invoices in SAP, a worker needs to open the application, log in, and enter all the required fields like Invoice Date, Posting Date, Amount, and others manually, which takes much time.
Automation solution
The example allows working with MIRO transactions in the SAP GUI desktop client by just starting it. The bot opens the client, logs in, fills in all required fields, and posts the invoice. As the result, a lot of time will be saved.
Reusable components
In this example, there are three reusable components:
- Calculate the current date and convert it to a string.
- Log in to the SAP GUI desktop client.
Example overview video
Preconditions
Before you start working, ensure all the requirements are met:
- Install:
- WorkFusion Studio (IA Cloud Developer)
- SAP GUI v. 7.40-7.50 connected to the environment
- Download the example.
Getting started
To get started, perform the following actions:
Extract the sample folder and drop it into your default workspace in WorkFusion Studio:
C:/Users/username/workfusion-workspace/rpae_project.Open the sample in WorkFusion Studio.
Go to Window > Preferences, expand WorkFusion Studio, and select the Secret Vault tab.
Press the Add button and enter
SAP_credsas Alias. Enter the SAP username in the Key column and the SAP password–in Value.
Press Apply and Close.
Edit the following variables:
sap_path: the path tosaplogon.execompany_codeamountpurchase_orderquantity
Click Play recording.
Script overview
On a 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
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 a string | |
transaction_type | String | Required to choose the right transaction type | Invoice |
sap_path | String | Path to 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), the bot pushes the current date to the
current_datevariable.
In the Date Format action, the bot converts the
current_datevariable into theinvoice_dateString variable with a specific format:
Log in to SAP GUI
Description: The group opens SAP GUI and logs into it.
tip
To reuse the group, make sure you 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, the bot launches SAP GUI using Launch Application, clicks the Log on button (Click Mouse) in a specific window (Window), and pastes credentials into the required fields (Enter Keystrokes).

Create and post incoming invoice
Description: The group allows opening the MIRO transaction for a specific company, filling in all required invoice fields, and posting into the system.
Create and post an 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 Mouse, Wait) fills in all required invoice fields (Invoice date, Amount, Purchase Order), clicks the Simulate button, and waits for the Simulate window to open.

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