SAP Driver
SAP Driver
This page describes only Sap Driver specific features and methods which may be different in other drivers.
Implementation which is common for all drivers is described in Drivers page. Please, read it before.
Prepare node for SAP Automation
SAP driver automates the actions are performed against SAP desktop client. Under the hood SAP driver employs ActiveX Component which requires manual steps need to be done ones by node administrator to prepare node for SAP automation:
- Setup SAP GUI For Windows 7.50 according to the https://www.sap.com/documents/2017/05/bc8d025a-b97c-0010-82c7-eda71af511fa.html
- Apply registry patch sap_driver_fix.reg from node agent package
- Install Microsoft Visual C++ Redistributable 2015-2019 x64 and/or x86
You also need to setup SAP Client connections that could be done by SAP user.
Prepare your SAP Server for RPA
Driver Initialization
You can initialize the driver in your automation process by the following way:
@Driver private SapDriver sapDriver;
Driver Params
Param name | Measure | Default Value | Description |
---|---|---|---|
DriverParams.All.EXPLICITLY_WAIT_TIMEOUT_SECONDS | seconds | 5 | Wait functions default timeout in seconds. |
DriverParams.All.EXPLICITLY_WAIT_POLLING_INTERVAL_MILLISECONDS | milliseconds | 500 | Wait functions default pooling interval in milliseconds. |
Opening and closing SAP application
To use SAP driver you have to start SAP session first. To do so you can either employ desktop driver or make use of sapshcut utility bundled with SAP Logon distribution.
Open SAP using sapshcut utility
Run
sapshcut
command with all the necessary arguments such as user and password, SID and client and othersString sapPath = "C:/Program Files (x86)/SAP/FrontEnd/SAPgui/sapshcut"; String user = "userid"; String password = "password"; String system = "S4H"; String client = "100"; getDriver().get(sapPath, user, password, "EN", system, null, null, client, tCode, null);
Runsapshcut -help
in command line to find out more avaiable argumentsAfter a certain time when SAP Frontend window appears the SapDriver session can be safely initialized
Open SAP using DesktopDriver
Start SAP Logon using desktop driver.
@Driver private DesktopDriver desktopDriver; ... desktopDriver.get("C:/Program Files (x86)/SAP/FrontEnd/SAPgui/saplogon.exe");
Select the required connection from list and run it.
DesktopSearch.UIQuery connectionQuery = DesktopSearch.UIQuery.builder().tagName("Text").name(sapConnectionName).build(); DesktopElement connection = getDriver().findElement(DesktopSearch.query(connectionQuery)); connection.sendKeys(Keys.ENTER);
SAP Frontend window will open which is a subject to SAP driver automation.
@Driver private SapDriver sapDriver; sapDriver.get();
Log into SAP Frontend with required credentials and perform other AP related actions using SAP Driver.
sapDriver.findElementById("wnd[0]/usr/txtRSYST-BNAME").setText(user); sapDriver.findElementById("wnd[0]/usr/pwdRSYST-BCODE").setText(password); sapDriver.findElementById("wnd[0]").sendKeys(SapKeyCode.ENTER); // other actions after user has been authenticated
Logout from SAP Frontend with SAP Driver
// logs out without prompt using command input sapDriver.findElementById("wnd[0]/tbar[0]/okcd").setText("/nex");
Working with UI Elements
Inspector
To define SAP Element ID run Scripting Tracker and refresh the object tree. Next click on target element using arrow button and copy value from ID field.
Below is the example of retreiving id for Material input field.
|
Find elements
Please, check the table which locators are supported by SapDriver:
Selector type |
---|
SapSearch.sapId |
SapSearch.sapName |
The initialized SAP driver can be used to locate page elements.
In order to do so the field ID must be passed to sapDriver.findElement(By sapId)
.
SapElement descriptionInput = sapDriver.findElement(SapSearch.sapId("wnd[0]/usr/txtRSYST-BNAME")); descriptionInput.setText("EasyRPA material");