UiPath Studio

UiPath Studio 指南

SAP 具体自动化技巧

常见用例

涉及 SAP 操作的工作流可归类到专门的自动化流程类别,因为它们牵涉到使用常见的可重用组件。建议自动化 SAP 登录流程,并将它划分成两个工作流:

  • One that opens the SAP GUI and selects the server connection by using the Open Application and Click activities.
  • One which regards the SAP login, includes Type Into activities to write in the username and credentials for the server connection, and a Click activity to select the login button.

SAP operations often involve populating a high number of rows in SAP tables, which can be done by taking the information from a newline-separated string and pasting it all at once in the SAP table. However, this approach is only applicable to the visible rows on the screen. The dynamic solution to populating all the rows in the table, including the ones that aren’t visible, is to use an If activity that would take the SAP Table Id as input and increase the rowCount until the element no longer exists. The activity counts the number of rows visible at once in the SAP GUI, adds the data from a string to the visible rows and uses the PageDown hotkey to get a new batch of empty rows to fill in the table.

行计数取决于 SAP 窗口的大小,因此建议在一开始将窗口最大化。

其他常用的 SAP 自动化工作流包括从不同 SAP 屏幕过账付款、登录并从 SAP 迁移数据到其他业务软件应用程序、搜索和提取 SAP 中的特定信息,或者生成报告和电子表格。

识别用户界面元素

在创建 SAP 工作流时,通常需要识别和操作各式各样的用户界面元素。大多数 SAP GUI 元素允许 API 交互;即,可以使用“模拟单击”和“模拟键入”输入方法来输入数据。

Note:

在某些情形中,如果文本框不支持数量较多的字符,“模拟键入”输入方法将不起作用。因此,系统会抛出错误。要避免这一问题,文本过长时应将它截断。

The Double Click activity can be used for navigating through branches in SAP, but it does not work if the Simulate Click method is enabled. One workaround is using the Double Click activity with the default Hardware Events settings or to check for another way of performing the same action, using a regular click on the element correlated with an anchor. One good practice is to use buttons instead of hotkeys to navigate, especially in menus.

某些情形中无法从 SAP 服务器加载完整的表格,也就是说只能从屏幕中抓取一定数量的行。有一种好方法是在循环中提取数据,同时结合向表格发送翻页指令,直到当前抓取的信息与之前的相同为止。

When dealing with table rows and columns, infinite loops in a Try Catch activity are recommended, especially when trying to read a table with an unknown number of rows. Read each row in an infinite loop until the operation fails and the Try Catch throws an error set in the workflow.

For reading special elements, use the Get Attribute activity, which shows hidden information.

SAP 警告

由于某些 SAP 自动化需要机器人遍历多个服务器连接,因此建议使用 SAP 页面标题来验证机器人是否登陆到特定工作流中所需的页面上。

此外,当工作流无法继续时,状态栏中的 SAP 消息也是不错的警告信息来源。在某些情形中,可以通过单击“Enter”按钮来删除 SAP 生成的警告。

另一种建议的良好做法是,在每一事务中使用 SAP 登录可重用组件来防止内存泄漏或捕获可造成 SAP 崩溃的问题。

错误处理

在某些情形中,SAP GUI 可能会在与服务器通信时冻结,进而造成机器人也僵停。因此,所有与 SAP 的交互都应限定时间并置于并行活动之中,该活动也应设有预期运行时间的延时,以及诸如关闭 SAP 进程等操作。

抛出异常而不终止 SAP GUI 通常不起作用,因为该活动也可能会冻结并等待 SAP 操作完成,然后才能抛出异常。

Updated 11 days ago


SAP 具体自动化技巧


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.