0

I am using VBA to read data from SAP GUI. Now I can open the destination page of SAP Logon, but cannot read data because I don't know table ID.

                        
Set Table = Session.findById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760")

This table ID is incorrect: wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_W/ssubPS_SUBSCR:SAPMM61R:0760

When the table (grid) shows up, how can I get its ID for VBA scripts?

From the SAP GUI technical information, I see:

  • Program name: SAPMM61R
  • Table name: MDSU

After click with the mouse on the table, its recorded script is like below:

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? (Session.findById("?"))

Thanks a lot!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Roselu
  • 3
  • 2
  • There are different types of table/grid UI elements. Here, you are talking about a [`GuiTableControl` object](https://help.sap.com/docs/search?q=GuiTableControl%20object&product=sap_gui_for_windows). – Sandra Rossi Jun 19 '23 at 18:31

1 Answers1

0

Not 100% sure if I understand the question, but the table name should be as below:

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
Jarron
  • 1,049
  • 2
  • 13
  • 29
  • Thank you for your reply! I cannot debug because I have not SAP testbed now. I need ask for the customer to provide a testbed for me to debug it. – Roselu Jan 14 '19 at 10:35
  • Thank you for your answer! Wonderful answer! I debug on the customer's test bed, now can get the data of table. – Roselu Jan 15 '19 at 07:41
  • Thanks again! Thanks again! Thanks again! – Roselu Jan 15 '19 at 07:42