其他分享
首页 > 其他分享> > RPA-Connect to session

RPA-Connect to session

作者:互联网

How to work with SAP (robocorp.com)

How to work with SAP

Robocorp supports automating SAP. The RPA.SAP library is based on the SapGuiLibrary that enables automating the SAP GUI application.

 

<iframe height="100%" src="https://www.youtube.com/embed/6dR5iOkhgGY" width="100%"></iframe>

 

Enable SAP Scripting Engine

SAP scripting must be enabled on the server and on the client.

SAP user with the required authorization should set the sapgui/user_scripting for the system. It is also recommended to set sapgui/user_scripting_per_user to allow scripting on per user basis and then set the authorization object S_SCR for defined users.

Server

Set two parameters (sapgui/user_scripting and sapgui/user_scripting_per_user):

SAP GUI Scripting Security Guide (PDF):

In some cases, it is not possible to enable SAP GUI Scripting for lack of a dedicated application server. This implies that users who are allowed to use SAP GUI Scripting work on the same server as others, so the support cannot be enabled for the server.

The problem can be solved by setting the rights to run SAP GUI Scripting per user. The new profile parameter sapgui/user_scripting_per_user allows the administrator then to enable SAP GUI Scripting support for specific users. Unless the administrator explicitly changes the value, this parameter is set to FALSE. If the profile parameter is set to TRUE the following happens:

  • On the login screen SAP GUI Scripting is available for every user.
  • After login, SAP GUI Scripting only remains available for those users that have the authorization for the Execute(16) action of the authorization object S_SCR in class BC_A.

Client

After user scripting is enabled on the server, each user with S_SCR authorization can enable the scripting in the SAP GUI client:

Opening a connection / Before running automation

Start the SAP Logon Pad application. Use the Connect To Session keyword to connect to the SAP Session.

After successful connection, use the Open Connection keyword to open a new connection from the SAP Logon Pad or Connect To Existing Connection to connect to a connection that is already open.

Here's an example for logging into SAP:

 
*** Settings ***
Library    RPA.SAP    WITH NAME    SAP
Library    RPA.Desktop.Windows    WITH NAME    Windows

*** Keywords ***
SAP Gui Login
    Disable Screenshots On Error
    Windows.Open Executable    ${EXE_PAD}    ${TITLE_PAD}
    Connect To Session
    ${secrets}=    Get Secret    sap
    SAP.Open Connection    ${secrets}[connection]
    SAP.Input Text    ${FIELD_CLIENT}    ${secrets}[client]
    SAP.Input Text    ${FIELD_USER}    ${secrets}[user]
    SAP.Input Password    ${FIELD_PASSWORD}    ${secrets}[password]
    SAP.Send Vkey    0

Also check the SAP Logon & Login example by Robocorp community member RoboHeart!

Locating or specifying elements

Specify elements starting from the window ID, for example, wnd[0]/tbar[1]/btn[8]. In some cases, the SAP ID contains backslashes. Escape these backslashes by adding another backslash in front of them.

Check the SAP - MM01 - Create Material example by Robocorp community member RoboHeart!

Screenshots (on error)

The RPA.SAP library has an option for automatic screenshots on error. This option is enabled by default. Use Disable Screenshots On Error to skip the screenshot functionality.

Alternatively, this option can be set when importing the library:

 
*** Settings ***
Library    RPA.SAP    screenshots_on_error=True    screenshot_directory=None

Example robots

Learn more about the libraries mentioned on this page:

2021年4月28日

标签:Scripting,GUI,RPA,session,Connect,SAP,scripting,user
来源: https://www.cnblogs.com/ricoo/p/15828956.html