Documentation: SAP Gui Scripting with connmove EasyCloud

 

Inhalt

 

Requirements    3

Record a script    4

Start at SAP Easy Access menu    4

Choose script path    4

Start recording    5

Call transaction AL08    5

Stop recording    6

Connect to the SAP GUI    7

Open a SAP GUI session    7

Run the script    7

Stop the SAP GUI connecction    8

Access the result value    8

Statusbar message    9

GUI elements    10

64bit PowerShell    11

GUI GridView    11

 

Requirements

  • SAP GUI must be installed on the client system.
  • SAP GUI Scripting must be enabled on the application server by setting the sapgui/user_scripting parameter.
  • SAP GUI Scripting must be enabled on the client system in the Option dialog of the SAP GUI.

 

Record a script

Start at SAP Easy Access menu


Choose script path


Start recording


Call transaction AL08



Stop recording


 

Connect to the SAP GUI

use 32bit PowerShell

Open a SAP GUI session

$sapGUIConnection
= Get-CmSapGuiConnect
-UserName
admin -Password
****** -Host
CMD002 -Hide
$false
-MultiLogon
$true

 

Optional parameter

  • Hide: Do not show the SAP GUI (default true)
  • MultiLogon: Allow multiple logons to the production system using the same user (default false)

Run the script

$result
= Invoke-CmSapGuiScripting
-FileName
c:tmpsapguial08.vbs $sapGUIConnection
–StatusbarOnly $true

 

Optional parameter:

  • StatusbarOnly: Return only the message displayed in the status bar (default false)

 

Stop the SAP GUI connecction

You may execute more scripts. When finished you have to call the Close-CmSapGuiConnect method:

Close-CmSapGuiConnect
$sapGUIConnection

 

Access the result value

The commandlet returns a List<String[]> object. The elements of the List<String[]> consists of a pair of strings ( GUI element type, value).

 

PS
> $result.GetType()

      IsPublic IsSerial Name                                     BaseType

      ——– ——– —-                                     ——–

      True     True     Object[]                                 System.Array

 

 

Statusbar message

The first element contains the status bar message:

 

PS> $result[0] GuiStatusbar Selection restricted to 200 hits

 

The statusbar message is empty at the AL08 example:

 

 

GUI elements

You can run several operations on the list, such as

 

PS
> $result.Count

53

PS
> $result.Get(10)

GuiLabel

Interactive Users

 

 

64bit PowerShell

You may use the cmdlet from a 64bit PowerShell by calling the start-job commandlet:

 

# Set the input parameter.

$argumentList
= $UserName, $Password, $HostName, $Client, $scriptPath

# Run the SAP GUI scripting command lets in a 32bit environment.

$rfcCheckResult
= start-job
{

    param($UserName, $Password, $HostName, $Client, $scriptPath)

    add-pssnapin
CmCmdlets;

    $sapGUIConnection
= Get-CmSapGuiConnect
-UserName
$UserName
-Password
$Password

-Host
$HostName
-Client
$Client
-Hide
$false
-MultiLogon
$true;

    Invoke-CmSapGuiScripting
-FileName
$scriptPath
$sapGUIConnection;

    $null
= Close-CmSapGuiConnect
$sapGUIConnection

    } -RunAs32 -ArgumentList
$argumentList
| wait-job
| Receive-Job

 

GUI GridView

On some dypros the data is displayed in a GridView. In this case the elements of the List<String[]> consists of a pair of strings ( SAP table column name, value).

 

PS
C:Windowssystem32> $result.Get(1)

BNAME

ADMIN

PS
C:Windowssystem32> $result.Get(2)

NAME_TEXT

Administrator Admin

PS
C:Windowssystem32> $result.Get(3)

CLASS

SUPER

PS
C:Windowssystem32> $result.Get(4)

ACCNT

PS
C:Windowssystem32> $result.Get(5)

LOCKICON

PS
C:Windowssystem32> $result.Get(6)

LOCKREASON

PS
C:Windowssystem32> $result.Get(7)

GLTGV

PS
C:Windowssystem32> $result.Get(8)

GLTGB

PS
C:Windowssystem32> $result.Get(9)

USTYP

A Dialog

PS
C:Windowssystem32> $result.Get(10)

REFUSER