我正在使用VBA从SAP读取数据。现在,我可以打开SAP的目标页面,但由于不知道表ID而无法读取数据。
Session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W").Select
Set Table = Session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760")
表ID不正确,wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760
当显示SAP系统时,显示表格(网格),如何获取VBA脚本的ID?
在SAP中,技术信息显示: 程式名称:SAPMM61R 表名称:MDSU
在SAP表格上单击鼠标后,以下是重新编写的脚本:
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS/txtMDSU-MNG02[2,4]").setFocus
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS/txtMDSU-MNG02[2,4]").caretPosition = 11
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS/txtMDSU-MNG02[2,6]").setFocus
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS/txtMDSU-MNG02[2,6]").caretPosition = 12
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS/txtMDSU-MNG02[2,7]").setFocus
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS/txtMDSU-MNG02[2,7]").caretPosition = 12
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS").columns.elementAt(2).width = 12
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS").columns.elementAt(3).width = 12
session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS/txtMDSU-MNG02[2,7]").caretPosition = 14
session.findById("wnd[0]").sendVKey 2
您能从以上信息中告诉我表ID是什么吗? Session.findById("?")
非常感谢!
答案 0 :(得分:0)
不能100%确定我是否理解这个问题,但表名应如下所示:
Dim targetTable As Object
Set targetTable = session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS")
您可能已经知道如何提取和输入数据,但是如果没有,请在下面进行编码。从表访问数据不同于网格访问数据:
MsgBox targetTable.getCell(TARGETROW, TARGETCOLUMN).Text 'Change TARGETROW to your row integer and TARGETCOLUMN to your column integer
targetTable.getCell(TARGETROW, TARGETCOLUMN).Text = "HELLO" 'Change TARGETROW to your row integer and TARGETCOLUMN to your column integer