SAP GUI 脚本在保存时处理两个可能的弹出窗口

SAP GUI script handling two possible popups when saving

为采购订单 (PO) 的价格更新创建脚本。

如果我尝试更新的价格在采购订单上已经相同,则会出现问题。然后没有可保存的内容,信息 弹出窗口 windows 显示“无数据更改”。这是脚本停止工作的地方,因为脚本的记录是基于新的价格不同并且可以保存。

我尝试将 if 语句添加到代码中,但它不起作用。新价格不同时不保存,需要保存。 它总是选择 Enter 并且没有使用 Else 语句。

session.findById("wnd[0]/tbar[0]/btn[11]").press 'Save on Menu bar

If session.ActiveWindow.Name = "wnd[1]" Then
   If session.findById("wnd[1]").text = "Information" then 
      session.findById("wnd[1]/tbar[0]/btn[0]").press 'If popup and it's only Information type press Enter

      objSheet.Cells(i, 3).Value = "No data changed"  'Information that no change has been done

   Else

      session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press  'Save in the popup window

      objSheet.Cells(i, 3) = "Updated" 'Information that the new price has been updated

   End if

通过删除 If session.ActiveWindow.Name = "wnd[1]" Then 脚本可以正常工作


   If session.findById("wnd[1]").text = "Information" then 
      session.findById("wnd[1]/tbar[0]/btn[0]").press 'If popup and it's only Information type then press Enter

      objSheet.Cells(i, 3).Value = "No data changed"  'Information that no change has been done

   Else

      session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press  'Save in the popup window

      objSheet.Cells(i, 3) = "Updated" 'Information that the new price has been updated

   End if