简体   繁体   English

我怎么知道SAP上的表ID,使用VBA从SAP读取数据

[英]How can I know the table ID on SAP,use VBA to read data from SAP

I am using VBA to read data from SAP. 我正在使用VBA从SAP读取数据。 Now I can open the destination page of SAP, but cannot read data because I don't know table ID. 现在,我可以打开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")

the table id is incorrect, 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

When the SAP system show, the table (grid) shows, how can I get it's ID for VBA scripts? 当SAP系统显示时,表格(网格)显示出来,如何获得VBA脚本的ID?

From the SAP, technical information shows: Program name: SAPMM61R Table name: MDSU 在SAP中,技术信息显示:程序名称:SAPMM61R表名称:MDSU

After click with the mouse on the table of SAP, it's scripts recored are the below: 在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

Can you tell me from the above info what the table id is? 您能从上面的信息中告诉我表ID是什么吗? Session.findById("?")

Thanks a lot! 非常感谢!

Not 100% sure if I understand the question, but the table name should be as below: 不能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")

You may already know how to extract and input data, but if not code below. 您可能已经知道如何提取和输入数据,但是如果没有下面的代码,则可能会知道。 To access data from a table is different to that of a grid: 从表访问数据不同于网格访问数据:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM