【问题标题】:How can I know the table ID on SAP,use VBA to read data from SAP如何知道 SAP 上的表 ID,使用 VBA 从 SAP 读取数据
【发布时间】:2019-01-14 09:09:55
【问题描述】:

我正在使用 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

你能从上面的信息告诉我table id是什么吗? Session.findById("?")

非常感谢!

【问题讨论】:

    标签: vba sap


    【解决方案1】:

    不是 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
    

    【讨论】:

    • 感谢您的回复!我无法调试,因为我现在没有 SAP 测试平台。我需要请客户提供一个测试台供我调试。
    • 感谢您的回答!精彩的答案!我在客户的测试台上调试,现在可以拿到表的数据了。
    • 再次感谢!再次感谢!再次感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-19
    • 1970-01-01
    相关资源
    最近更新 更多