Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan_schnell
Active Contributor
A few days ago I presented here the new version of Scripting Tracker. The new version supports now native PowerShell code generating.

Here an example of a PowerShell script from a logon process.



You see the SAP GUI for Windows screen and the recorded script inside Scripting Tracker. With Scripting Tracker it is seamless possible to switch in the PowerShell ISE and here you find the complete code. Now you can use all the possibilities of the ISE like single step debugging or examination of variables.

Scripting Tracker uses a COM bridge for the communication with SAP GUI Scripting, which I presented here. On this way it is possible to generate code which is nearly similar to well known VBScript.

Here an example of an activity in an tree control in VBScript:

session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").expandNode "0000000003"

session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "0000000004"

Here the same example in PowerShell:

$ID = Invoke-Method $session "findById" @("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell")

Invoke-Method $ID "expandNode" @("0000000003")

$ID = Invoke-Method $session "findById" @("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell")

Set-Property $ID "selectedNode" @("0000000004")

The comparisation shows that code in VBScript contains one line for one activity and PowerShell two lines. The code generation creates for findById one call of Invoke-Method and with the returned ID it calls the next activity e.g. like expandNode.



In some cases the code generation creates well known code like

$ID.elementAt(3).width = 19

which should sets the width of the third column of the table control.

But the method elementAt doesn't work in this context, it is necessary to replace it with Item like

$ID.Item(3).width = 19

which works perfectly.



Since version 5, which I presented here, offers PowerShell new language features like classes.

It has many advantages more to use PowerShell instead VBScript with SAP GUI Scripting:

  1. PowerShell is the actual Scripting language in Windows environments.

  2. It is available on all Windows systems without further installations.

  3. It is in further development.

  4. Its security mechanisms are technically mature.

  5. PowerShell offers an Integrated Scripting Environment (ISE) e.g. for single step debugging.

  6. etc.

5 Comments
Labels in this area