The capabilities described on this page are included in Appian's standard capability tier. Usage limits may apply. |
The SAP module allows your robotic tasks to interact with SAP applications. The robotic task will utilize the components of the SAP Graphical User Interface (GUI) in order to complete actions or obtain information.
To work with your SAP applications, you will need to set up your robot to work with SAP GUI Scripting. SAP GUI Scripting is an automation interface that enhances the capabilities of SAP GUI for Windows and Java. You will utilize an element inspector tool to create methods around these SAP elements.
The following diagram illustrates the components of SAP GUI. Each of these components has a corresponding object in the SAP module. For more information about the SAP GUI components and their hierarchy, see the SAP GUI Scripting API help.
You can get instances of these objects from the methods provided by the GuiMainWindow class:
1
2
3
4
5
6
7
8
IGuiSession guiSession = sap.getConnection().getOpenSessions().get(0);
GuiMainWindow activeWindow = (GuiMainWindow) guiSession.getActiveWindow();
GuiMenuBar menuBar = activeWindow.getMenuBar();
GuiToolBar toolBar = activeWindow.getToolBar();
GuiUserArea userArea = activeWindow.getUserArea();
GuiStatusBar statusBar = activeWindow.getStatusBar();
For more information on interacting with GuiApplication, GuiConnection, and GuiSession in the SAP module, see the com.novayre.jidoka.sap.api
package in the Javadocs. For more information on interacting with GuiMainWindow, see the com.novayre.jidoka.sap.api.window
package in the Javadocs.
To use the SAP module, ensure you complete the following prerequisites:
Your SAP version might affect what JRE you can use on your host machine:
Additionally, the file jacob-1.18-x86.dll
or jacob-1.18-x64.dll
must be in the same directory as the Appian RPA agent executable (jidoka.exe
). The .dll
file is copied by the Appian RPA agent to the corresponding directory the first time the robot performs the robotic task.
To interact with SAP, you need to utilize SAP GUI Scripting. After setting up your robot, enable SAP GUI Scripting on the server.
If SAP GUI Scripting is not active on the server, initializing the SAP module on the platform will throw a SapFatalException.
To interact with an element on an SAP window, you will need to know its type and unique identifier. To identify this information, download the Tracker tool. This tool allows you to inspect the SAP GUI elements.
To begin using the SAP module, connect the SAP module to an open application. Due to security restrictions, SAP GUI Scripting can't control the first opened window. You have to open SAP GUI and select the target system using other methods in the Appian RPA API.
Note: The first time you run the SAP module, you must run it as an administrator in order to configure the items below. After, you will need to restart the Appian RPA agent to load the .dll
file.
To initialize the SAP module, you must first open SAP GUI. To open SAP GUI, you need to start a Windows process and execute the saplogon.exe
.
Use the ProcessBuilder object to start a Windows process. Within the object, call the executable file defined in the
SapConstants.App.SAP_EXECUTABLE constant. By default, the installation path in Windows 7 is C:\\Program Files(x86)\\SAP\\FrontEnd\\SAPgui\\saplogon.exe
.
After opening SAP GUI, use the keyboard to enter the name of the SAP system. This will prompt the SAP login window. From this window, the robotic task can begin to take over the application.
To connect the SAP module instance to the open application, execute the following code snippet:
1
2
3
4
5
6
7
8
9
// Instantiate the SAP module if you haven't done so before
if (sap == null) {
sap = ISap.getInstance(this);
}
// Appian RPA SAP Module initialization
if (!sap.isInitialized()) {
sap.init();
}
Below is an example of a complete SAP initialization:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/** The Appian RPA SAP module. */
private IGuiApplication sap;
/**
* SAP open action.
*
* @throws JidokaException the jidoka exception
*/
public void sapOpen() throws JidokaException {
Path sapPath = Paths.get(SapConstants.App.SAP_EXECUTABLE_PATH, SapConstants.App.SAP_EXECUTABLE);
// open SAP logon window
ProcessBuilder pb = new ProcessBuilder(sapPath.toString());
try {
pb.start();
// Wait for the initial window title (For example 'SAP Logon 750')
waitFor.window(30, true, true, SapConstants.Titles.SAP_LOGON_WINDOW_TITLE);
server.info("SAP application opened");
// Type the SAP connection name and press the key "Enter". In this example we use 'SAP Demo'
keyboard.type(SAP_CONNECTION).pause(1000).enter();
waitFor.window(SapConstants.Timeouts.MEDIUM_WAIT, true, SapConstants.Titles.SAP_LOGON_WINDOW_TITLE_FIRST);
server.info("Connected to: " + SAP_CONNECTION);
// Instantiate the SAP module if it wasn't done before
if (sap == null) {
sap = ISap.getInstance(this);
}
// Appian RPA SAP Module initialization
if (!sap.isInitialized()) {
sap.init();
}
GuiMainWindow win = (GuiMainWindow) sap.getCurrentSession().getActiveWindow();
win.iconify();
win.maximize();
windows.pause(2000);
server.info("Initializing Appian RPA SAP module");
} catch (IOException | JidokaUnsatisfiedConditionException e) {
throw new JidokaException("SAP could not be opened: " + e.getMessage(), e);
}
}
Once the SAP module is initialized, locate the type and unique identifier of elements on the SAP window so you can reference them in your robotic task.
To identify the elements on your SAP window, open the Tracker tool. The Tracker tool displays a tree, known as a component tree, with all SAP sessions and its scripting objects. When you select an element from the tree, you can view more detailed information about the element, such as its ID, type, and text.
Each component tree begins with an SAP window. For example, if you have an SAP window with an open transaction and a pop-window, you will see two component trees in the Tracker beginning with an SAP window: /app/con[0]/ses[0]/wnd[0] and /app/con[0]/ses[0]/wnd[1]
.
When you open the SAP window component of the tree, you will see an acronym for each area of an SAP window.
They provide access to the following elements:
By default, the Tracker will inspect the elements of the active SAP session. To see all available windows, go to the menu and click Tools > Scan to scan scripting objects of all sessions.
Once you've obtained an element's type and unique identifier, use the findById() method to reference the element in your robotic task. This method is available in the GuiVContainer class and returns an instance of GuiComponent by its ID.
To use this method, first use the Tracker tool to identify the element's information. For example, a Tracker is inspecting an element on the following SAP window. In the Tracker, the second tab is selected in the component tree.
Based on the Tracker, you can see the tab is located inside the user area as well as the element's information:
/app/con[0]/ses[0]/wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB02
To reference the element in your robotic task, you must first call GuiMainWindow since this is the entry point for interaction between the robotic task and the SAP GUI window.
You know that the element is in the user area, so you need to obtain the GuiUserArea instance of the active window. After, use the findById() method of the GuiUserArea instance and the element's ID to locate the element.
The ID obtained from the Tracker is an absolute path, however, you only need the relative path to locate the element. Additionally, since the method returns a GuiComponent instance, you can use the GuiTab instance since all elements on an SAP window's user interface extend this class.
1
2
3
4
5
GuiFrameWindow activeWindow = sap.getCurrentSession().getActiveWindow();
GuiUserArea userArea = activeWindow.getUserArea();
GuiTab tab2 = userArea.findById("tabsMENU_TABSTRIP/tabpTAB02");
tab2.select();
SAP Java Module