SAP GUI 获取 excel 以从 SAP 系统中的 table 复制一些项目

SAP GUI getting excel to copy some items from a table in SAP system

我正在尝试编写一些代码来从 sap 中提取数据,然后将其放入 Excel table。现在,我的 GUI 进入了正确的 itemnumber。在这里,我一直在尝试使用 GUI 记录器获取一些有用的代码。我已尝试 select 数据,并在此处打开详细信息和 selected 数据。我遇到的麻烦是 GUI 生成的代码没有给我 .value.setfocus 或类似的东西。所以我不知道如何处理这个问题。 GUI 中的代码如下所示:

session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nymm_pricelist"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtS_MATNR-LOW").Text = Cells(currentline, 1).Value
session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").Text = Cells(currentline, 2).Value
session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").SetFocus
session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").caretPosition = 4
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").CurrentCellColumn = "LOCALSALES_KBETR"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").ContextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectContextMenuItem "&DETAIL"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").setCurrentCell 4, "VALUE"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").selectedRows = "4"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").ContextMenu
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").CurrentCellRow = 8
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").selectedRows = "8"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").ContextMenu
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").CurrentCellRow = 10
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").selectedRows = "10"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").ContextMenu
session.findById("wnd[1]/tbar[0]/btn[0]").press

关于如何做到这一点有什么想法吗?

您可以尝试以下方法:

. . .
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").ContextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectContextMenuItem "&DETAIL"
set myGrid = session.findById("wnd[1]/usr/cntlGRID/shellcont/shell")
myText_4 = myGrid.getcellvalue (4,"VALUE")
myText_8 = myGrid.getcellvalue (8,"VALUE")
myText_10 = myGrid.getcellvalue (10,"VALUE")
session.findById("wnd[1]/tbar[0]/btn[0]").press

此致, 脚本人