2

I am using a macro in an Excel file that runs the SAP GUI. There is a step where, when I click a button in SAP there will be another window that pops up.

For that I have written a code like this:

session.findbyid("wnd[0]/XX/btnXX").press
session.findbyid("wnd[1]/XX/btnXXX").press

There is a button (btnXXX) in the window (wnd[1]). But when I execute this query, I am getting an error object not found for findbyid.

When I keep the break point and execute it, it is throwing error on 2nd line in the above code. I try to pick the activewindow.name and it shows wnd[0] still. Here the issue is wnd[1] is not getting opened.

Does somebody know why the 2nd "button press" doesn't work?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Peak
  • 21
  • 1
  • 5
  • 1
    Is that a non-SAPGUI popup? What generates the SAP GUI recorder? Can you explain what screens you work with/show them? – Sandra Rossi Sep 26 '19 at 13:38
  • It's a SAP GUI popup. Recorder also generates the wnd[1] – Peak Sep 27 '19 at 06:57
  • Please add screen shots, it's essential. Currently I find it practically impossible to help. Moreover, could you create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) and paste it here. – Sandra Rossi Sep 27 '19 at 07:33
  • I have the same error. Something as simple as the transaction bar not responding to pressing the check button but will work if I press enter. Wondering if you were able to solve this. – Adam Milecki Jan 15 '20 at 20:20

1 Answers1

1

You should be able to replace all mouse clicks with keyboard strokes.

Replace:

session.findbyid("wnd[0]/XX/btnXX").press

With:

session.findById("wnd[0]").sendVKey(N)

Where N is the linked hot-key ID.

To get the exact command, use SAP script recording and only use the keyboard to transition between views and windows. The easiest way to determine how is to hover your mouse over the buttons you would normally click to learn the hot-key then record the hot-key.

Note 1) So far I have found that btn[XX] always maps to sendVKey(XX), but I can't be certain this is always the case.

Note 2) sendVKey always appears to be referenced off the window (wnd[Y]) even if a button is another layer down (/tbar, /usr, etc.).

Adam Milecki
  • 1,738
  • 10
  • 15