Hello community,

Microsoft Windows 7 is in business now. With Windows 7 we get the PowerShell, the new command-line shell and scripting language. You find a lot of information about Windows PowerShell here: http://technet.microsoft.com/en-us/library/bb978526.aspx.

So far so good, here is an example, how to use SAP GUI Scripting inside Windows PowerShell. It opens the transaction code SE16 and view the table USR01. The scripting code comes direct from the SAP GUI Scripting Recorder. Only the double quotes must change to `” and the EOL to `n.

Enjoy it.

Cheers
Stefan

#-Begin-----------------------------------------------------------------

  $VB = New-Object -COMObject MSScriptControl.ScriptControl
  
$Cmd = @"
Set SapGuiAuto = GetObject(`"SAPGUI`")`n
Set application = SapGuiAuto.GetScriptingEngine`n
Set connection = application.Children(0)`n
Set session = connection.Children(0)`n
session.findById(`"wnd[0]/tbar[0]/okcd`").text = `"/nse16`"`n
session.findById(`"wnd[0]/tbar[0]/btn[0]`").press`n
session.findById(`"wnd[0]/usr/ctxtDATABROWSE-TABLENAME`").text = `"USR01`"`n
session.findById(`"wnd[0]/tbar[1]/btn[7]`").press`n
session.findById(`"wnd[0]/tbar[1]/btn[8]`").press`n
"@
  
  $VB.Language = "VBScript"
  $VB.AllowUI = $TRUE
  $VB.ExecuteStatement($Cmd)

#-End-------------------------------------------------------------------
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply