cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Keys in SAP with VBS

0 Kudos

Hi Everyone,

I have a little issue in SAP when I try to automate some data extraction.

Usually I record an extraction that I do by hand, and then adapt the vbs script for details (for example to put variables like dates or path where to extract the files) and everything was almost working well.

Why almost? Because after trying for many hours I did not find a solution on how to tell VBS to click on the menubar (usually : List -> Save -> File...)

I mean, when I record it in a script it is written like : session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[2]").select

BUT when I run it, it does not work.

So I was evading the problem by using virtual keys, because there was always a shortcut to Save File, like pressing F9 or something.

But the last report I have to automate is slightly different in the way that there is no shortcut assigned to Save File...

So I tried many things, like finding a way to press the menubar, or searching for generic shortcuts to save file... But nothing worked

I then realized I could access the menu bar with the keyboard, by pressing : Alt+L, Alt+S, Alt+F, so I tried recording what I was doing, but this keyboard interaction was not recorded in the script.

So I tried to send them in the script, like : session.findById("wnd[0]").sendkeys("%l") but I get an error in SAP telling me that this could not be used.

So now here comes my questions :

- How can I do?

- Is there a list of virtual keys code of SAP where I can find how to send Alt+L for example.

- Or is there a way to click on the menubar?

Thanks in advance,

I have spent ages trying things and looking on the web, and saw several forum posts with a similar question but always unanswered.

Vince

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi, although this solved my problem (in that case),

I have a new similar problem

I need, still in a vbscript, to access a menu in the menu bar (Environment -> Query Areas)

Which I can access through alt+v then alt+a

Or by typing :

either Alt, right arrow (x5), then down arrow and then enter

or F10, right arrow (x5), then down arrow and then enter

I tried things like :

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

or

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

and though it does not give errors, it doesn't do anything

Has anybody a miracle solution? Like another shortcut %something or a way to really send keys to SAP ?

Thanks in advance

0 Kudos

a little up

Former Member
0 Kudos

Sorry, it was my mistake.

In the advanced editor I can insert text from the clip board, of course.

netkid

Former Member
0 Kudos

Hi Vince,

there's a short way to download the actual SAP window:

Write %PC in the white transaction field.

The code look's like this:

. . .

session.findById("wnd[0]/tbar[0]/okcd").text = "%PC"     'start download

session.findById("wnd(0)/tbar[0]/btn[0]").press               'Go on-Button

. . .

Or yor record a new script.

The important thing is the transaction field is acually shown in the menu-bar

while you record a new script.

Maybe this helps.

Bye, netkid

@ forum moderator: why can't you copy text from clipboard in the advanced editor.

    is there a trick?

0 Kudos

Thank you sooooo much netkid

it is exactly what I needed !