Quantcast
Channel: SCN : Document List - Scripting Languages
Viewing all 100 articles
Browse latest View live

Tip: New AutoIt Scripting Language Version Available

$
0
0

Hello community,

 

since a few days a new version of AutoIt scripting language is available here. It is the version 3.3.14 from the 10th of July 2015. You can find the complete list of changes here. AutoIt is a very powerful scripting language, you can find a few examples here, here and here. You can use AutoIt with SAP GUI Scripting, SAP ActiveX Controls and SAP NetWeaver RFC Library. I try out all this scenarios and all works well as expected. Thanks to Jonathan Bennett and the AutoIt Team.

 

Enjoy it.

 

Cheers

Stefan


How To Get Data From SAP NW Gateway Interface with OData via VBScript

$
0
0

Hello community,

 

SAP offers a new interface technology on OData platform - you can find much more about OData here. The OData interface is primarly for use with the new UI5 technology - you can find much more information here and about OpenUI5 here. But it is also possible to use the SAP NetWeaver Gateway Interface with VBScript. Here an easy example how to get data:

 

'-Begin-----------------------------------------------------------------

 

  '-Constants-----------------------------------------------------------

    Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

 

  '-Function MyASC------------------------------------------------------

  '-

  '- (c) 2001 Antonin Foller, Motobit Software

  '- www.motobit.com/tips/detpg_base64encode/

  '-

  '---------------------------------------------------------------------

    Function MyASC(OneChar)

      If OneChar = "" Then

        MyASC = 0

      Else

        MyASC = Asc(OneChar)

      End If

    End Function

 

  '-Function Base64Encode-----------------------------------------------

  '-

  '- (c) 2001 Antonin Foller, Motobit Software

  '- www.motobit.com/tips/detpg_base64encode/

  '-

  '---------------------------------------------------------------------

    Function Base64Encode(inData)

 

      '-Variables-------------------------------------------------------

        Dim cOut, sOut, i, nGroup, pOut, sGroup

 

      'For each group of 3 bytes

        For i = 1 To Len(inData) Step 3

 

          'Create one long from this 3 bytes.

            nGroup = &H10000 * Asc(Mid(inData, i, 1)) + _

              &H100 * MyASC(Mid(inData, i + 1, 1)) + _

              MyASC(Mid(inData, i + 2, 1))

 

          'Oct splits the long To 8 groups with 3 bits

            nGroup = Oct(nGroup)

 

          'Add leading zeros

            nGroup = String(8 - Len(nGroup), "0") & nGroup

 

          'Convert To base64

            pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _

              Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _

              Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _

              Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)

 

          'Add the part To OutPut string

            sOut = sOut + pOut

 

          'Add a new line For Each 76 chars In dest (76*3/4 = 57)

          'If (I + 2) Mod 57 = 0 Then

          '  sOut = sOut + vbCrLf

          'End If

 

        Next

 

      Select Case Len(inData) Mod 3

        Case 1: '8 bit final

          sOut = Left(sOut, Len(sOut) - 2) + "=="

        Case 2: '16 bit final

          sOut = Left(sOut, Len(sOut) - 1) + "="

      End Select

 

      Base64Encode = sOut

    End Function

 

  '-Sub Main------------------------------------------------------------

    Sub Main()

 

      '-Variables-------------------------------------------------------

        Dim Http, Authorization, User, Password, Result

 

      Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")

      If IsObject(Http) Then

 

        User = "MyUser"

        Password = "Secret"

        Authorization = Base64Encode(User & ":" & Password)

 

        Http.Open "GET", "http://sid.MyHost.de:8330" & _

          "/sap/opu/odata/ZDELIVERY_SRV/DeliveriesSet?$format=xml", True

        Http.SetRequestHeader "Authorization", "Basic " & Authorization

        Http.Send

 

        Http.WaitForResponse 10

 

        MsgBox Http.StatusText & vbCrLf & Http.GetAllResponseHeaders

        If Http.Status = 200 Then

          Result = Http.ResponseText

          MsgBox Result

        End If

 

        Set Http = Nothing

      End If

 

    End Sub

 

  '-Main----------------------------------------------------------------

    Main

 

'-End-------------------------------------------------------------------

 

In the Main subroutine we create an object from WinHttp.WinHttpRequest - a standard library which should be available on any Windows OS installation. We set the user and password variables and encode them into Base64 format. Now we open a connection to the target SAP system and OData service. We set the Authorization keyword of the request header with Basic and the encoded user and password. Now the get request is send to the backend system and we wait for response. The status text and the complete response header is shown in a message box. If the status is ok (200) the response text is set in the variable result and it is also shown in a message box.

 

001.jpg

As you can see it is very easy to use the OData interface from the SAP NetWeaver Gateway inside a scripting language like VBScript.

 

Enjoy it.

 

Cheers

Stefan

Review: PowerShell Script Version 4 with SAPIENs ActiveXPosh Version 3

$
0
0

Hello community,

 

I presented here the possibility how to use PowerShell script inside ABAP and I presented here and here how to combine PowerShell script with Visual Basic Script (VBS), in the context of SAP GUI Scripting and GuiXT. In all cases I use SAPIENs ActiveXPoshV3 library. Today I update my system to PowerShell version 4 with dotNET framework 4.5.2 and check the functionality of ActiveXPoshV3 library. All works well and as expected.

 

Enjoy PowerShell inside ABAP and SAP GUI Scripting furthermore.

 

Cheers

Stefan

Tip: How To Use 32bit COM Libraries In 64bit VBA IDE Which Can Not Be Loaded As Reference

$
0
0

Hello community,

 

I described here in the comment an unexpected behavior of a COM library. If I want to load the same library in a 64bit VBA IDE I get the error message shown below.

 

001.jpg

Message box text: Reference to the given file can not be added.

 

But the same library works in 32bit VBA IDE perfect. I don't know the reason for this behavior. To get around this I use the following way:

 

#If Win64 Then

  Dim SAP As Object

#Else

  Dim SAP As CCo.COMNWRFC

#End If

 

To differentiate between a 64bit and a 32bit VBA IDE I use the compilation constant Win64. If the code runs in a 64bit environment the variable is declared as an object, otherwise it is a reference. This works perfect to execute the code.

The only disadvantage is, that it is not possible to use the object browser and code completion with the methods and properties of the library in the VBA IDE.

 

Enjoy it.

 

Cheers

Stefan

How To Use COM Functions in PowerShell Easily, in Comparison with VBScript, Using the Example of CCo

$
0
0

Hello community,

 

over two years ago I presented COM Connector (CCo) here - CCo makes the using of the NetWeaver RFC library very easy.

Slowly but surely the landscape of the script language environments changed in Windows OS - from Windows Script Host (WSH) to PowerShell. From this point of view it seems good to take also a movement.

 

Here a PowerShell example how to get all installed SAP components and its version numbers in comparison with a VBScript which offers the same information.

 

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


  #-Constants-----------------------------------------------------------

    $RFC_OK = 0

    $VarByRef = -1


  #-Includes------------------------------------------------------------

    ."Includes\COM.ps1"

 

  #-Function Get-SAPComponents------------------------------------------

    Function Get-SAPComponents {

 

      $SAP = $null

      $SAP = Create-Object "COMNWRFC"

      if ($SAP -eq $null) {

        Break

      }

 

      $hRFC = Invoke-Method $SAP "RfcOpenConnection" @(

        "ASHOST=NSP, SYSNR=00, CLIENT=001, USER=BCUSER")

      if ($hRFC -eq 0) {

        Free-Object $SAP

        Break

      }

 

      $hFuncDesc = Invoke-Method $SAP "RfcGetFunctionDesc" @(

        $hRFC, "DELIVERY_GET_INSTALLED_COMPS")

      if ($hFuncDesc -eq 0) {

        $rc = Invoke-Method $SAP "RfcCloseConnection" $hRFC

        Free-Object $SAP

        Break

      }

 

      $hFunc = Invoke-Method $SAP "RfcCreateFunction" $hFuncDesc

      if ($hFunc -eq 0) {

        $rc = Invoke-Method $SAP "RfcCloseConnection" $hRFC

        Free-Object $SAP

        Break

      }

 

      $rc = Invoke-Method $SAP "RfcInvoke" @($hRFC, $hFunc)

      if ($rc -eq $RFC_OK) {

 

        $rc = Invoke-Method $SAP "RfcGetTable" @(

          $hFunc, "TT_COMPTAB", $VarByRef)

        if ($rc -eq $RFC_OK) {

 

          $hTable = Get-Property $SAP "lngByRef"

          $rc = Invoke-Method $SAP "RfcGetRowCount" @(

            $hTable, $VarByRef)

          $RowCount = Get-Property $SAP "lngByRef"

 

          $rc = Invoke-Method $SAP "RfcMoveToFirstRow" $hTable

 

          for ($i = 1; $i -le $RowCount ; $i++) {

 

            $Row = Invoke-Method $SAP "RfcGetCurrentRow" $hTable

 

            $rc = Invoke-Method $SAP "RfcGetChars" @(

              $Row, "COMPONENT", $VarByRef, 30)

            $charBuffer = Get-Property $SAP "strByRef"

            $txt = $txt + $charBuffer

 

            $rc = Invoke-Method $SAP "RfcGetChars" @(

              $Row, "RELEASE", $VarByRef, 10)

            $charBuffer = Get-Property $SAP "strByRef"

            $txt = $txt + $charBuffer

 

            $rc = Invoke-Method $SAP "RfcGetChars" @(

              $Row, "EXTRELEASE", $VarByRef, 10)

            $charBuffer = Get-Property $SAP "strByRef"

            $txt = $txt + $charBuffer

 

            $rc = Invoke-Method $SAP "RfcGetChars" @(

              $Row, "COMP_TYPE", $VarByRef, 1)

            $charBuffer = Get-Property $SAP "strByRef"

            $txt = $txt + $charBuffer + "`r`n"

 

            if ($i -lt $RowCount) {

              $rc = Invoke-Method $SAP "RfcMoveToNextRow" $hTable

            }

 

          }

        }

      }

 

      $rc = Invoke-Method $SAP "RfcDestroyFunction" $hFunc

      $rc = Invoke-Method $SAP "RfcCloseConnection" $hRFC

      Free-Object $SAP

      Remove-Variable SAP

      $txt

    }

 

  #-Function Main-------------------------------------------------------

    Function Main {

      $Components = Get-SAPComponents

      Write-Host $Components

    }

 

  #-Main----------------------------------------------------------------

    Main

 

#-End-------------------------------------------------------------------

 

 

Here now the VBScript:

 

'-Begin-----------------------------------------------------------------

 

  '-Directives----------------------------------------------------------

    Option Explicit

 

  '-Constants-----------------------------------------------------------

    Const RFC_OK = 0

 

  '-Function GetSAPComponents-------------------------------------------

    Function GetSAPComponents()

 

      '-Variables-------------------------------------------------------

        Dim SAP, hRFC, rc, hFuncDesc, hFunc, hTable, RowCount, i, Row

        Dim charBuffer, strText

 

      Set SAP = CreateObject("COMNWRFC")

      If Not IsObject(SAP) Then

        Exit Function

      End If

 

      hRFC = SAP.RfcOpenConnection("ASHOST=NSP, SYSNR=00, " & _

        "CLIENT=001, USER=BCUSER")

      If hRFC = 0 Then

        Set SAP = Nothing

        Exit Function

      End If

 

      hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, _

        "DELIVERY_GET_INSTALLED_COMPS")

      If hFuncDesc = 0 Then

        rc = SAP.RfcCloseConnection(hRFC)

        Set SAP = Nothing

        Exit Function

      End If

 

      hFunc = SAP.RfcCreateFunction(hFuncDesc)

      If hFunc = 0 Then

        rc = SAP.RfcCloseConnection(hRFC)

        Set SAP = Nothing

        Exit Function

      End If

 

      If SAP.RfcInvoke(hRFC, hFunc) = RFC_OK Then

        If SAP.RfcGetTable(hFunc, "TT_COMPTAB", hTable) = RFC_OK Then

          rc = SAP.RfcGetRowCount(hTable, RowCount)

          rc = SAP.RfcMoveToFirstRow(hTable)

          For i = 1 To RowCount

            Row = SAP.RfcGetCurrentRow(hTable)

            rc = SAP.RfcGetChars(Row, "COMPONENT", charBuffer, 30)

            strText = strText & Trim(charBuffer) & " "

            rc = SAP.RfcGetChars(Row, "RELEASE", charBuffer, 10)

            strText = strText & Trim(charBuffer) & " "

            rc = SAP.RfcGetChars(Row, "EXTRELEASE", charBuffer, 10)

            strText = strText & Trim(charBuffer) & " "

            rc = SAP.RfcGetChars(Row, "COMP_TYPE", charBuffer, 1)

            strText = strText & Trim(charBuffer) & vbCrLf

            If i < RowCount Then

              rc = SAP.RfcMoveToNextRow(hTable)

            End If

          Next

        End If

      End If

 

      rc = SAP.RfcDestroyFunction(hFunc)

      rc = SAP.RfcCloseConnection(hRFC)

      Set SAP = Nothing

 

      GetSAPComponents = strText

    End Function

 

  '-Sub Main------------------------------------------------------------

    Sub Main()

      MsgBox GetSAPComponents()

    End Sub

 

  '-Main----------------------------------------------------------------

    Main

 

'-End-------------------------------------------------------------------

 

 

As you can see it is very comparable.

 

To establish the comparibility I use an include file, which stores the COM access routines like Create-Object, Invoke-Method etc.

 

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

 

  #-Function Create-Object----------------------------------------------

    Function Create-Object {

      param([String] $objectName)

      try {

        New-Object -ComObject $objectName

      }

      catch {

        [Void] [System.Windows.Forms.MessageBox]::Show(

          "Can't create object", "Important hint", 0)

      } 

    }

 

  #-Function Get-Object-------------------------------------------------

    Function Get-Object {

      param([String] $objectName)

      [Microsoft.VisualBasic.Interaction]::GetObject($objectName)

    }


  #-Sub Free-Object-----------------------------------------------------

    Function Free-Object {

      param([__ComObject] $object)

      [Void] [System.Runtime.Interopservices.Marshal]::ReleaseComObject($object)

    }

 

  #-Function Get-Property-----------------------------------------------

    Function Get-Property {

      param([__ComObject] $object, [String] $propertyName)

      $object.GetType().InvokeMember($propertyName,

        [System.Reflection.Bindingflags]::GetProperty,

        $null, $object, $null)

    }

 

  #-Sub Set-Property----------------------------------------------------

    Function Set-Property {

      param([__ComObject] $object, [String] $propertyName,

        $propertyValue)

      [Void] $object.GetType().InvokeMember($propertyName,

        [System.Reflection.Bindingflags]::SetProperty,

        $null, $object, $propertyValue)

    }

 

  #-Function Invoke-Method----------------------------------------------

    Function Invoke-Method {

      param([__ComObject] $object, [String] $methodName,

        $methodParameters)

      $object.GetType().InvokeMember($methodName,

        [System.Reflection.Bindingflags]::InvokeMethod,

        $null, $object, $methodParameters, $null, $null, $null)

    }

 

#-End-------------------------------------------------------------------

 

001.jpg

 

With this tiny include you can use COM functions in PowerShell almost like in VBScript.

 

Let the games begin.

 

Cheers

Stefan

How to use Windows PowerShell Script inside ABAP

$
0
0

Hello community,

 

Windows PowerShell is a mix of command-line shell and scripting language. You find more Information about PowerShell here and here.

 

With the free COM library ActiveXPosh.dll from SAPIEN you can also use PowerShell inside ABAP.

 

Here an example how to get all services and its state.

 

"-Begin-----------------------------------------------------------------
  Program zPSTest.

    "-TypePools---------------------------------------------------------
      Type-Pools OLE2 .

    "-Constants--------------------------------------------------------
      Constants OUTPUT_CONSOLE Type i Value 0.
      Constants OUTPUT_WINDOW Type i Value 1.
      Constants OUTPUT_BUFFER Type i Value 2.

    "-Variables---------------------------------------------------------
      Data PS Type OLE2_OBJECT.
      Data Result Type i Value 0.
      Data strResult Type String Value ''.
      Data tabResult Type Table Of String.

    "-Main--------------------------------------------------------------
      Create Object PS 'SAPIEN.ActiveXPoSHV3'.

      If sy-subrc = 0 And PS-Handle <> 0 And PS-Type = 'OLE2'.

        Call Method Of PS 'Init' = Result Exporting #1 = 0.

        If Result = 0.

          Call Method Of PS 'IsPowerShellInstalled' = Result.

          If Result <> 0.

            Set Property Of PS 'OutputMode' = OUTPUT_BUFFER.

            Call Method Of PS 'Execute' Exporting
              #1 = 'Get-WmiObject -class Win32_Service | Format-Table -property Name,State'.

            Call Method Of PS 'OutputString' = strResult.

            Split strResult At cl_abap_char_utilities=>cr_lf
              Into Table tabResult.

            Loop At tabResult Into strResult.
              Write: / strResult.
            EndLoop.

          EndIf.

        EndIf.

        Free Object PS.
      EndIf.

"-End-------------------------------------------------------------------

 

You can use with PowerShell all dotNET and Windows standard libraries. On this way you can extend your possibilities.

 

Cheers

Stefan

How To Get Data From SAP NW Gateway Interface with OData via PowerShell

$
0
0

Hello community,

 

a month ago I wrote here about the possibility to get data from SAP NW gateway interface with OData via VBScript. Here now an equivalent solution for PowerShell.

 

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

 

  $User = "MyUser"

  $Password = Read-Host -Prompt "Passwort" -AsSecureString

  $Cred = New-Object System.Management.Automation.PSCredential($User, $Password)

 

  $RequestURI = "http://sid.MyHost.de:8630/sap/opu/odata/Z_AM_MSG_SRV/MSGSet?$format=xml"

  $Records = Invoke-RestMethod -Uri $RequestURI -Credential $Cred -Method Get

 

  ForEach($Record in $Records) {

    $Properties = $Record.Content.Properties

    Write-Host $Properties.LastName $Properties.ForeName

  }

 

#-End-------------------------------------------------------------------

 

With PowerShell it is absolut easy to get access to the XML object hierarchy.

 

Enjoy it.

 

Cheers

Stefan

Tip: How to Code a GuiXT Conformable Dynamic Link Library (DLL)

$
0
0


Hello community,

 

I show here an example how to call the Windows API function ShellExecute inside a GuiXT script. You can call a DLL function with the command Call, look here for the technical documentation. And now I show an example, how to code your own dynamic link library (DLL) with FreeBASIC to use it inside a GuiXT script.

 

As you can see, in the section "Calling a dll function" in the technical documentation from Synactive, the Call function from GuiXT needs only pointer to strings as input and output arguments. With this knowledge I implement a DLL in FreeBASIC with one export function expMsgBox. These export function has only string arguments, two input and one output. Inside the export function I call a simple MessagBox function with the input parameters. The result of the MessageBox function I convert to a string and put it to the output argument.


'-Begin-----------------------------------------------------------------
'-
'- FreeBasic Dynamic Link Library (DLL) for GuiXT
'- Compile it with -dll option.
'-
'- Author: Stefan Schnell
'-
'-----------------------------------------------------------------------

 

  '-Includes------------------------------------------------------------
    #Include Once "windows.bi"

 

  Extern "Windows-MS"

 

    '-Function expMsgBox------------------------------------------------
      Function expMsgBox Alias "expMsgBox" (ByVal inMsg As String, _
        ByVal inTitle As String, ByVal outRes As String) As Long Export

 

        '-Variables-----------------------------------------------------
          Dim resMsgBox As Long

 

        resMsgBox = MessageBox(NULL, inMsg, inTitle, MB_YESNOCANCEL)
        outRes = Str(resMsgBox)
        expMsgBox = resMsgBox

 

      End Function

 

  End Extern

 

'-End-------------------------------------------------------------------

 

 

I call this DLL function from GuiXT with the following script:


//-Begin----------------------------------------------------------------

 

  Call "expMsgBox" dll="FreeBasic.dll" In="Hello World" In="GuiXT" Out="res"
  Message "&[res]"

 

//-End------------------------------------------------------------------

 

 

It works perfect with GuiXT.

msgbox.JPG

 

result.JPG

 

With this possibility you can combine the power of GuiXT script with the power of FreeBASIC. GuiXT is standard part of the SAP GUI for Windows installation and FreeBASIC is a free/open source compiler.

 

15/11/25 Addition

This example above is originated with FreeBasic 0.90. With higher compiler versions the example don't work anymore, so it is not recommended. Here an equivalent PureBasic example:

 

; Begin-----------------------------------------------------------------

;

; PureBasic Dynamic Link Library (DLL) for GuiXT

;

; Author: Stefan Schnell

;

; ----------------------------------------------------------------------

 

  ; Function expMsgBox--------------------------------------------------

    ProcedureDLL.i expMsgBox(inMsg.s, inTitle.s, *outRes)

 

      ; Variables-------------------------------------------------------

        Protected resMsgBox.i

 

      resMsgBox = MessageRequester(inTitle, inMsg, #PB_MessageRequester_YesNoCancel)

      PokeS(*outRes, Str(resMsgBox))

      ProcedureReturn resMsgBox

 

    EndProcedure

 

; End-------------------------------------------------------------------

 

Cheers

Stefan


CCo (COM Connector) for SAP NetWeaver RFC Library for Scripting Languages

$
0
0

Hello community,

 

SAP offers different connectors to develop ABAP compatible components and applications. JCo for Java environments, NCo for dotNET languages and the NetWeaver RFC SDK for C++. But what's up if you work neither with Java or dotNET environments nor with C++?

 

Here is another alternative, CCo - the COM Connector for SAP. CCo is a COM library and offers wrappers around all functions of the SAP NetWeaver RFC library. So it is possible to use all functionalities of the SAP NetWeaver RFC library inside any language which support COM technic.

 

With CCo it is easily possible to use the SAP NetWeaver RFC functions inside VBScript, Visual Basic for Applications (VBA) or AutoIt script.

 

Here a VBScript example to connect an SAP system:

 

'-Begin-----------------------------------------------------------------  '-Directives----------------------------------------------------------    Option Explicit  '-Variables-----------------------------------------------------------    Dim SAP, hRFC, rc  '-Main----------------------------------------------------------------    Set SAP = CreateObject("COMNWRFC")    If IsObject(SAP) Then      SAP.About      hRFC = SAP.RfcOpenConnection("ASHOST=ABAP, SYSNR=00, " & _        "CLIENT=001, USER=BCUSER")      If hRFC Then        MsgBox "Check connection with TAC SMGW in the SAP system"        rc = SAP.RfcCloseConnection(hRFC)      End If      Set SAP = Nothing    End If

'-End-------------------------------------------------------------------

 

Here a VBA example to ping an SAP system:

 

'-Begin-----------------------------------------------------------------  Option Explicit  '-Constants-----------------------------------------------------------    Const RFC_OK = 0  '-Sub Ping------------------------------------------------------------    Sub Ping()      '-Variables-------------------------------------------------------        Dim SAP As CCo.COMNWRFC        Dim hRFC As Long        Dim rc As Integer        Dim hFunc, hFuncDesc As Long      Set SAP = CreateObject("COMNWRFC")      If IsObject(SAP) Then        hRFC = SAP.RFCOPENCONNECTION("ASHOST=ABAP, SYSNR=00, " & _          "CLIENT=001, USER=BCUSER")        If hRFC Then          '-Variant1----------------------------------------------------            hFuncDesc = SAP.RFCGETFUNCTIONDESC(hRFC, "RFC_PING")            If hFuncDesc Then              hFunc = SAP.RFCCREATEFUNCTION(hFuncDesc)              If hFunc Then                If SAP.RFCINVOKE(hRFC, hFunc) = RFC_OK Then                  Debug.Print "Ping successful"                Else                  Debug.Print "Ping not successful"                End If                SAP.RFCDESTROYFUNCTION hFunc              End If            End If          '-Variant2----------------------------------------------------            If SAP.RFCPING(hRFC) = RFC_OK Then              Debug.Print "Ping successful"            Else              Debug.Print "Ping not successful"            End If          rc = SAP.RFCCLOSECONNECTION(hRFC)        End If        Set SAP = Nothing      End If    End Sub

'-End-------------------------------------------------------------------

 

To the duality of accesses via SAP GUI Scripting and RFC with scripting languages

scriptingstructure.jpg

 

CCo opens a powerful second channel to communicate with an SAP backend. You can code in your favorite COM-enabled scripting language and use two ways: on the one hand the SAP GUI Scripting to communicate via SAP GUI for Windows with an SAP system, and on the other hand the COM Connector (CCo) to communicate via SAP NetWeaver RFC library with an SAP application server.

CCo is an ideal complementation to SAP GUI Scripting in this application area. You can e.g. use the wide range of thousands of remote-enabled function modules from an SAP system. Use the transaction code BAPI to open the BAPI explorer and find a lot in the alphabetical hierarchy tree.

Enrich your SAP GUI Scripting operation processes. Get information easy and fast via CCo RFC interface in your scripting environment. Combine the best of both worlds.

 

 

Hint: CCo has at the moment experimental character. Don't use it in production environments.

 

Hint: CCo needs SAP RFC SDK, you find it here.

 

Download

You find CCo here: http://cco.stschnell.de

 

2015/12/06

  • An update is available.
  • Add the property UsePwdRequest to disable the password requester in the case of using SAPNWRFC.INI via DEST connection parameter or the using of MYSAPSSO2 connection parameter.

 

2015/11/20

  • New Version 1.7 is available.
  • Externalization of the routine to register the library without admin rights as script, because this function doesn't work with Windows 10.
  • Checked with Windows 10 x64.
  • Checked with actual RFC library patch level 38.

 

2015/01/01

  • New Version 1.5 is available.
  • It includes now for arguments by reference a set of typed attributes, e.g. lngByRef for a long variable by reference. This attributes gets and sets the arguments by reference, on any method with a corresponding in and out argument.
  • So it is now possible to use CCo with JavaScript inside IE11 in edge mode, to use it in UI5 environments. New examples are included.
  • Also you can use CCo on the same way with PowerShell. New examples are included.
  • CCo is now backwards compatible, the new SAP functions since the first PL - implemented in version 1.4 - doesn't create an error message at the creation of the instantiation.
  • Checked with actual RFC library patch level 33.

 

2014/12/21:

  • New Version 1.4 is available.
  • Implementation of the functions RfcAppendNewRows, RfcGetRowType, RfcLanguageIsoToSap, RfcLanguageSapToIso and RfcSetCpicTraceLevel - Hint: From this point CCo is not backward compatible, use always the actual SAP NetWeaver RFC library.
  • New examples to create SAP server applications - synchronous and asynchronous.
  • New interprocess communication functions (IPC) to enable implementation of other processes.

 

2014/12/11:

  • Updated Version 1.3 is available.
  • No functional changes, only a few interface changes in the context of bgRFC calls.
  • Many new examples, e.g. VBScript BAPI examples, t/qRFC and bgRFC examples.
  • Checked with actual RFC library patch level 31.
  • Corrected register routine.

 

2014/09/21:

  • Updated Version 1.2 is available.
  • No functional changes, new compilation with advanced header files.
  • Checked with actual RFC library patch level 25.
  • Corrected register routine.

 

 

Comments are welcome.

 

Cheers

Stefan

Review: PowerShell Script Version 5 with SAPIENs ActiveXPosh Version 3

$
0
0

Hello community,

 

I presented here and here the possibility how to use PowerShell script inside ABAP and I presented here and here how to combine PowerShell script with Visual Basic Script (VBS), in the context of SAP GUI Scripting and GuiXT. Also I presented here the review how to us PowerShell script version 4, in all cases I use SAPIENs ActiveXPosh library. Two weeks ago I updated my system to PowerShell version 5 with dotNET framework 4.6 and check the functionality of ActiveXPoshV3 library. All works well and as expected.

 

'-Begin-----------------------------------------------------------------


  '-Directives----------------------------------------------------------

    Option Explicit


  '-Constants-----------------------------------------------------------

    Const OUTPUT_BUFFER = 2


  '-Sub Main------------------------------------------------------------

    Sub Main()


      '-Variables-------------------------------------------------------

        Dim PS, PSCode, PSVersion


      Set PS = CreateObject("SAPIEN.ActiveXPoSHV3")

      If IsObject(PS) Then

 

        PS.OutputMode = OUTPUT_BUFFER

 

        If PS.Init(vbFalse) = 0 And PS.IsPowerShellInstalled() <> 0 Then

 

          PSCode = "Write-Host -Separator '' " + _

            "$PSVersionTable.PSVersion.Major . " + _

            "$PSVersionTable.PSVersion.Minor . " + _

            "$PSVersionTable.PSVersion.Build . " + _

            "$PSVersionTable.PSVersion.MinorRevision"

          PSCode = PSCode & vbCrLf

 

          PS.Execute(PSCode)

          PSVersion = PS.OutputString()

          PS.ClearOutput()

          MsgBox PSVersion, vbOkOnly, "PowerShell version"

 

        End  If

        Set PS = Nothing

      Else

        MsgBox "Can't create ActiveXPoSH", vbOkOnly, "Important hint"

      End If

 

    End Sub


  '-Main----------------------------------------------------------------

    Main


'-End-------------------------------------------------------------------

 

001.JPG

 

Enjoy PowerShell inside ABAP and SAP GUI Scripting furthermore.

 

Cheers

Stefan

How to use Freestyle BASIC Script Language (FBSL) inside ABAP

$
0
0

Hello community,


in this forum we only discus how to connect SAP from different scripting languages. We never talk about the possibility how to use a scripting language from the SAP side. I published a little bit in 2009 about this theme in my blog with AutoItX. But AutoItX, the ActiveX component of Autoit, is, compared with AutoIt, restricted in its functionality. Now from this point I want to introduce another brilliant script language: Freestyle BASIC Script Language.

 

Freestyle BASIC Script Language (FBSL) is a multi-syntax all-in-one high-level language (HLL) development environment. Its interpretative layer is a vastly extended superset of traditional BASIC that targets seamless integration of FBSL applications with Windows API and third-party dynamic link libraries. Its integrated Dynamic Assembler and Dynamic C JIT compiler layers enable the user to interleave BASIC code with verbatim Intel-style assembly and ANSI C, respectively. You could it find FBSL here, but the domain is not reachable (2016/01/22).

 

To use FBSL inside ABAP I build an ActiveX library, called FBSLX. FBSLX contains wrapper functions around the library FBSL.dll. With FBSLX you have the possibility to use FBSL inside any language which is COM-enabled, also ABAP. The integration of FBSL insisde ABAP offers inter alia the possibilities to use on the presentation server easily

  • API/DLL functions,
  • a console window for input and/or output,
  • a GUI window,
  • memory functions,
  • memory map files for interprocess communication (IPC),
  • etc. etc. etc.

 

Here an example how easy it is to use FBSL inside ABAP:

 

"-Begin-----------------------------------------------------------------
  Program ZFBSL.

 

    "-Constants---------------------------------------------------------
      Constants CrLf(2) Type c Value %_CR_LF.

 

    "-Variables---------------------------------------------------------
      Data oFBSL Type OLE2_OBJECT.
      Data Buffer Type String Value ''.
      Data rc Type i.
      Data RetVal Type i.

 

    "-Macros------------------------------------------------------------
      Define _.
        Concatenate Buffer &1 CrLf Into Buffer.
      End-Of-Definition.

 

      Define Flush.
        Call Function 'AC_SYSTEM_FLUSH' Exceptions Others = 1.
      End-Of-Definition.

 

    "-Main--------------------------------------------------------------
      Create Object oFBSL 'FbslX'.

      If sy-subrc <> 0 Or  oFBSL-Handle = 0 Or oFBSL-Type <> 'OLE2'.
        CallFunction'ZFBSL_WININC'.
        Call Function 'ZFBSL_DLL'.

        Call Function 'ZFBSLX'.
        Create Object oFBSL 'FbslX'.
      EndIf.

 

      If sy-subrc = 0 And oFBSL-Handle > 0 And oFBSL-Type = 'OLE2'.

 

        CallMethodcl_gui_frontend_services=>get_sapgui_workdir
          ChangingSAPWORKDIR=WorkDirExceptionsOthers=1.
        Concatenate'#Include "'WorkDir'\Windows.inc"'IntoWinInc.

 

"-FBSL script begin-----------------------------------------------------

 

_ WinInc
_ '#Option Strict'.
_ '#AppType GUI'.

 

_ 'Dim %rc'.
_ 'rc = Msgbox(Null, "Message", "Title", MB_ABORTRETRYIGNORE)'.
_ 'Return rc'.

 

"-FBSL script end-------------------------------------------------------

 

        "-Here we execute the script------------------------------------
          Call Method Of oFBSL 'ExecuteScriptBuffer' = rc
            Exporting #1 = Buffer.
          Flush.

 

        "-Here we get the return value of the script--------------------
          Call Method Of oFBSL 'GetReturnValueInteger' = RetVal.
          Flush.

 

        Write: RetVal.

 

        Free Object oFBSL.

      EndIf.

 

"-End-------------------------------------------------------------------

 

FBSL offers a lot of new possibilities to integrate the presentation server in the context of ABAP on the application server. To implement FBSL complete in the ABAP context I use BinFile2ABAP, it works excellent.

 

Further links:

  • Here an experimental ABAP code, how to use ANSI C code inside ABAP via this FBSL environment and here an example how to use C code inside ABAP.
  • Here an ABAP code, how to use a drop zone.
  • Here a FBSL code, how to create an SAP server application.

 

Update 2014/10/11

  • FBSLX is outdated now, an new library, called ScriptX, replaces FBSLX.

 

Teapot.JPG

 

Here another example which shows  a Mandelbrot benchmark test with FbslX and FBSL inside ABAP.

 

zMandelbrot.jpg

 

Comments are welcome.

 

Enjoy it.

 

Cheers
Stefan

How to use Freestyle BASIC Script Language (FBSL) with SAP GUI Scripting

$
0
0

Hello community,

 

Freestyle BASIC Script Language (FBSL - but the domain is not reachable [2016/01/22]) is a true multitalent. It is possible to use it inside ABAP, to build client and server applications and to use it with SAP GUI Scripting, as the example here shows. It is only a simple logon, but it shows how to use FBSL in this case.


//-Begin----------------------------------------------------------------

 

  //-Directives---------------------------------------------------------
    #AppType Console
    #Option Strict

 

  //-Includes-----------------------------------------------------------
    #Include <Windows.inc>
 
  //-Main---------------------------------------------------------------
    Sub Main()

 

      //-Variables------------------------------------------------------
        Dim %SAPROTWrapper, %SapGuiAuto, %application, %connection
        Dim %session

 

      SAPROTWrapper = CreateObject("SapROTWr.SapROTWrapper", "")
      If Not SAPROTWrapper Then
        ExitProgram
      End If

 

      SapGuiAuto = GetValue("%o", SAPROTWrapper, ".GetROTEntry(%s)", _
        "SAPGUI")
      If Not SapGuiAuto Then
        ExitProgram
      End If

 

      application = GetValue("%o", SapGuiAuto, ".GetScriptingEngine")
      If Not application Then
        ExitProgram
      End If

 

      connection = GetValue("%o", application, ".Children(%d)", 0)
      If Not connection Then
        ExitProgram
      End If

 

      session = GetValue("%o", connection, ".Children(%d)", 0)
      If Not session Then
        ExitProgram
      End If

 

      PutValue(session, ".findById(%s).text = %s", _
        "wnd[0]/usr/txtRSYST-MANDT", "001")
      PutValue(session, ".findById(%s).text = %s", _
        "wnd[0]/usr/txtRSYST-BNAME", "BCUSER")
      PutValue(session, ".findById(%s).text = %s", _
        "wnd[0]/usr/pwdRSYST-BCODE", "minisap")
      PutValue(session, ".findById(%s).text = %s", _
        "wnd[0]/usr/txtRSYST-LANGU", "EN")
      CallMethod(session, ".findById(%s).sendVKey %d", _
        "wnd[0]", 0)

 

      ReleaseObject(SAPROTWrapper)

 

    End Sub

 

//-End------------------------------------------------------------------

 

FBSL can compile scripts to executable. On this way you can deliver your SAP GUI script to any target computer on Windows platform, without any dependencies.

 

Good Scripting.

 

Cheers

Stefan

Tip: How To Detect Modifications of Interfaces in Different Versions of a COM Library

$
0
0

Hello community,

 

nearly one year ago I presented here the possibility how to analyze the interface of COM/ActiveX libraries. A few days ago I presented here the possibility to create ABAP wrapper classes with it. Here now another tiny use case: Detecting differences in interfaces of different versions of a COM library.


In a normal case a manufacturer of a software package doesn't documented any tiny modification of the interfaces of the using COM/ActiveX libraries. But for us, the programmers, could be the knowledge of the modifications very important. So it is necessary to analyze differences. It is also possible to use my base module for this kind of analyzing. Here an example script how to create a simple text file from the interface of a COM/ActiveX library.

 

'-Begin-----------------------------------------------------------------

'-

'- Script to write interface of a COM library into a text file

'-

'- Author: Stefan Schnell

'-

'-----------------------------------------------------------------------

 

  '-Directives----------------------------------------------------------

    Option Explicit

 

  '-Constants-----------------------------------------------------------

    Const ForWriting = 2

 

  '-Function GetInterface-----------------------------------------------

    Function GetInterface(LibName)

 

      '-Variables-------------------------------------------------------

        Dim TypeLibInf, Interface

 

      Set TypeLibInf = CreateObject("COM_TYPELIBINF")

      If IsObject(TypeLibInf) Then

        Interface = TypeLibInf.COM_TYPELIBINF(LibName)

        Set TypeLibInf = Nothing

        GetInterface = Interface

      End If

 

    End Function

 

  '-Sub WriteInterface--------------------------------------------------

    Sub WriteInterface(LibName, FileName)

 

      '-Variables-------------------------------------------------------

        Dim Interface, SplitInterface, FSO, TS, i

 

      Interface = GetInterface(LibName)

      SplitInterface = Split(Interface, ";")

 

      Set FSO = CreateObject("Scripting.FileSystemObject")

      If IsObject(FSO) Then

        Set TS = FSO.OpenTextFile(FileName, ForWriting, True)

        If IsObject(TS) Then

          For i = 0 To UBound(SplitInterface)

            TS.WriteLine SplitInterface(i)

          Next

          TS.Close

          Set TS = Nothing

        End If

        Set FSO = Nothing

      End If

 

    End Sub

 

  '-Sub Main------------------------------------------------------------

    Sub Main()

 

      WriteInterface "sapfewse.ocx", "sapfewse.txt"

 

    End Sub

 

  '-Main----------------------------------------------------------------

    Main()

 

'-End-------------------------------------------------------------------

 

On this way you can create easily a text file from the interfaces of an older version and from a newer version of a COM/ActiveX library. So you see the differences fast and clear. The following image shows exemplary the differences between an older and a newer version of the SAP front end scripting engine library (sapfewse.ocx).

 

001.JPG

 

It should now not a big problem to create a script which contains all library names to create those kind of interface documentations and to find the differences automatically.

 

Hint: The TypeLibInf library offers three interfaces, a StdDLL, a COM and a Java interface. So you can use it from any language. Examples are available in ABAP, Java, Python and VBScript.

 

You can download TypeLibInf here.

 

Enjoy it.

 

Cheers

Stefan

Data Binding in SAPUI5

How to use SAP GUI Scripting Inside Windows PowerShell (Part 2)

$
0
0

Hello community,

 

two and a half year ago I wrote here about the possiblity how to use SAP GUI Scripting with Windows PowerShell. But this solution uses Microsoft Script Control engine and it is not clear how the future will look like. So I develop a solution which works with PowerShell without the Microsoft Script Control engine:

 

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

 

  #-Get-Property--------------------------------------------------------

    function Get-Property {

      param([__ComObject] $object, [String] $propertyName)

      $object.GetType().InvokeMember($propertyName,

        "GetProperty", $NULL, $object, $NULL)

    }

 

  #-Set-Property--------------------------------------------------------

    function Set-Property {

      param([__ComObject] $object, [String] $propertyName,

        $propertyValue)

      [Void] $object.GetType().InvokeMember($propertyName,

        "SetProperty", $NULL, $object, $propertyValue)

    }

 

  #-Invoke-Method-------------------------------------------------------

    function Invoke-Method {

      param([__ComObject] $object, [String] $methodName,

        $methodParameters)

      $output = $object.GetType().InvokeMember($methodName,

        "InvokeMethod", $NULL, $object, $methodParameters)

      if ( $output ) { $output }

    }

 

  #-Main----------------------------------------------------------------

    $SapGuiAuto = [microsoft.visualbasic.Interaction]::GetObject("SAPGUI")

    $application = Invoke-Method $SapGuiAuto "GetScriptingEngine"

    $connection = Get-Property $application "Children" @(0)

    $session = Get-Property $connection "Children" @(0)

 

    $ID = Invoke-Method $session "findById" @("wnd[0]/usr/txtRSYST-MANDT")

    Set-Property $ID "Text" @("001")

    $ID = Invoke-Method $session "findById" @("wnd[0]/usr/txtRSYST-BNAME")

    Set-Property $ID "Text" @("BCUSER")

    $ID = Invoke-Method $session "findById" @("wnd[0]/usr/pwdRSYST-BCODE")

    Set-Property $ID "Text" @("minisap")

    $ID = Invoke-Method $session "findById" @("wnd[0]/usr/txtRSYST-LANGU")

    Set-Property $ID "Text" @("EN")

 

    $ID = Invoke-Method $session "findById" @("wnd[0]")

    Invoke-Method $ID "sendVKey" @(0)

 

#-End-------------------------------------------------------------------

 

Hint: The wrapper functions are from Bill Stewart - thanks for that.

 

Here the equivalent code but with Microsoft Script Control engine:

 

#-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]/usr/txtRSYST-MANDT`").text = `"001`"`n

session.findById(`"wnd[0]/usr/txtRSYST-BNAME`").text = `"BCUSER`"`n

session.findById(`"wnd[0]/usr/pwdRSYST-BCODE`").text = `"minisap`"`n

session.findById(`"wnd[0]/usr/txtRSYST-LANGU`").text = `"EN`"`n

session.findById(`"wnd[0]`").sendVKey 0`n

"@

 

  $VB.Language = "VBScript"

  $VB.AllowUI = $TRUE

  $VB.ExecuteStatement($Cmd)

 

#-End-------------------------------------------------------------------

 

As you can see looks the code a little bit unusual, but on this way you use only a VB.net function and PowerShell natively.

 

Enjoy it.

 

Cheers

Stefan


Tip: New AutoIt Scripting Language Version Available

$
0
0

Hello community,

 

since a few days a new version of AutoIt scripting language is available here. It is the version 3.3.14 from the 10th of July 2015. You can find the complete list of changes here. AutoIt is a very powerful scripting language, you can find a few examples here, here and here. You can use AutoIt with SAP GUI Scripting, SAP ActiveX Controls and SAP NetWeaver RFC Library. I try out all this scenarios and all works well as expected. Thanks to Jonathan Bennett and the AutoIt Team.

 

Enjoy it.

 

Cheers

Stefan

How To Get Data From SAP NW Gateway Interface with OData via VBScript

$
0
0

Hello community,

 

SAP offers a new interface technology on OData platform - you can find much more about OData here. The OData interface is primarly for use with the new UI5 technology - you can find much more information here and about OpenUI5 here. But it is also possible to use the SAP NetWeaver Gateway Interface with VBScript. Here an easy example how to get data:

 

'-Begin-----------------------------------------------------------------

 

  '-Constants-----------------------------------------------------------

    Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

 

  '-Function MyASC------------------------------------------------------

  '-

  '- (c) 2001 Antonin Foller, Motobit Software

  '- www.motobit.com/tips/detpg_base64encode/

  '-

  '---------------------------------------------------------------------

    Function MyASC(OneChar)

      If OneChar = "" Then

        MyASC = 0

      Else

        MyASC = Asc(OneChar)

      End If

    End Function

 

  '-Function Base64Encode-----------------------------------------------

  '-

  '- (c) 2001 Antonin Foller, Motobit Software

  '- www.motobit.com/tips/detpg_base64encode/

  '-

  '---------------------------------------------------------------------

    Function Base64Encode(inData)

 

      '-Variables-------------------------------------------------------

        Dim cOut, sOut, i, nGroup, pOut, sGroup

 

      'For each group of 3 bytes

        For i = 1 To Len(inData) Step 3

 

          'Create one long from this 3 bytes.

            nGroup = &H10000 * Asc(Mid(inData, i, 1)) + _

              &H100 * MyASC(Mid(inData, i + 1, 1)) + _

              MyASC(Mid(inData, i + 2, 1))

 

          'Oct splits the long To 8 groups with 3 bits

            nGroup = Oct(nGroup)

 

          'Add leading zeros

            nGroup = String(8 - Len(nGroup), "0") & nGroup

 

          'Convert To base64

            pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _

              Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _

              Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _

              Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)

 

          'Add the part To OutPut string

            sOut = sOut + pOut

 

          'Add a new line For Each 76 chars In dest (76*3/4 = 57)

          'If (I + 2) Mod 57 = 0 Then

          '  sOut = sOut + vbCrLf

          'End If

 

        Next

 

      Select Case Len(inData) Mod 3

        Case 1: '8 bit final

          sOut = Left(sOut, Len(sOut) - 2) + "=="

        Case 2: '16 bit final

          sOut = Left(sOut, Len(sOut) - 1) + "="

      End Select

 

      Base64Encode = sOut

    End Function

 

  '-Sub Main------------------------------------------------------------

    Sub Main()

 

      '-Variables-------------------------------------------------------

        Dim Http, Authorization, User, Password, Result

 

      Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")

      If IsObject(Http) Then

 

        User = "MyUser"

        Password = "Secret"

        Authorization = Base64Encode(User & ":" & Password)

 

        Http.Open "GET", "http://sid.MyHost.de:8330" & _

          "/sap/opu/odata/ZDELIVERY_SRV/DeliveriesSet?$format=xml", True

        Http.SetRequestHeader "Authorization", "Basic " & Authorization

        Http.Send

 

        Http.WaitForResponse 10

 

        MsgBox Http.StatusText & vbCrLf & Http.GetAllResponseHeaders

        If Http.Status = 200 Then

          Result = Http.ResponseText

          MsgBox Result

        End If

 

        Set Http = Nothing

      End If

 

    End Sub

 

  '-Main----------------------------------------------------------------

    Main

 

'-End-------------------------------------------------------------------

 

In the Main subroutine we create an object from WinHttp.WinHttpRequest - a standard library which should be available on any Windows OS installation. We set the user and password variables and encode them into Base64 format. Now we open a connection to the target SAP system and OData service. We set the Authorization keyword of the request header with Basic and the encoded user and password. Now the get request is send to the backend system and we wait for response. The status text and the complete response header is shown in a message box. If the status is ok (200) the response text is set in the variable result and it is also shown in a message box.

 

001.jpg

As you can see it is very easy to use the OData interface from the SAP NetWeaver Gateway inside a scripting language like VBScript.

 

Enjoy it.

 

Cheers

Stefan

Review: PowerShell Script Version 4 with SAPIENs ActiveXPosh Version 3

$
0
0

Hello community,

 

I presented here the possibility how to use PowerShell script inside ABAP and I presented here and here how to combine PowerShell script with Visual Basic Script (VBS), in the context of SAP GUI Scripting and GuiXT. In all cases I use SAPIENs ActiveXPoshV3 library. Today I update my system to PowerShell version 4 with dotNET framework 4.5.2 and check the functionality of ActiveXPoshV3 library. All works well and as expected.

 

Enjoy PowerShell inside ABAP and SAP GUI Scripting furthermore.

 

Cheers

Stefan

How to use Windows PowerShell Script inside ABAP

$
0
0

Hello community,

 

Windows PowerShell is a mix of command-line shell and scripting language. You find more Information about PowerShell here and here.

 

With the free COM library ActiveXPosh.dll from SAPIEN you can also use PowerShell inside ABAP.

 

Here an example how to get all services and its state.

 

"-Begin-----------------------------------------------------------------
  Program zPSTest.

    "-TypePools---------------------------------------------------------
      Type-Pools OLE2 .

    "-Constants--------------------------------------------------------
      Constants OUTPUT_CONSOLE Type i Value 0.
      Constants OUTPUT_WINDOW Type i Value 1.
      Constants OUTPUT_BUFFER Type i Value 2.

    "-Variables---------------------------------------------------------
      Data PS Type OLE2_OBJECT.
      Data Result Type i Value 0.
      Data strResult Type String Value ''.
      Data tabResult Type Table Of String.

    "-Main--------------------------------------------------------------
      Create Object PS 'SAPIEN.ActiveXPoSHV3'.

      If sy-subrc = 0 And PS-Handle <> 0 And PS-Type = 'OLE2'.

        Call Method Of PS 'Init' = Result Exporting #1 = 0.

        If Result = 0.

          Call Method Of PS 'IsPowerShellInstalled' = Result.

          If Result <> 0.

            Set Property Of PS 'OutputMode' = OUTPUT_BUFFER.

            Call Method Of PS 'Execute' Exporting
              #1 = 'Get-WmiObject -class Win32_Service | Format-Table -property Name,State'.

            Call Method Of PS 'OutputString' = strResult.

            Split strResult At cl_abap_char_utilities=>cr_lf
              Into Table tabResult.

            Loop At tabResult Into strResult.
              Write: / strResult.
            EndLoop.

          EndIf.

        EndIf.

        Free Object PS.
      EndIf.

"-End-------------------------------------------------------------------

 

You can use with PowerShell all dotNET and Windows standard libraries. On this way you can extend your possibilities.

 

Cheers

Stefan

Scripting Tracker - Development Tool for SAP GUI Scripting

$
0
0

Hello community,

 

over two years ago I presented here the lite version of Scripting Tracker. Scripting Tracker is a utility and a replacement to the SAP GUI Scripting Development Tools. It is a SAP GUI analyzer and recorder on SAP GUI Scripting base. Now I decided to make all features of Scripting Tracker free available. In this case it means that the recording module is also free available from now.

 

tracker001.jpg

The analyzer shows a clearly arranged tree with all SAP sessions and its scripting objects. Also it shows for each scripting object, after the selection in the tree with a single mouse click, a lot of technical details like e.g. ID, position etc.

tracker002.jpg

With the recorder the program offers the possibility to record, edit and execute your SAP GUI activities in Visual Basic, AutoIt, MiniRobot or PowerShell script language. E.g. with the + button you enriches the source with information comment lines about the transaction, title, dynpro - program name and screen number - and the session number. With Scripting Tracker you have full visual control about the creating code, now it couldn't be easier to use SAP GUI Scripting.

 

You can find Scripting Tracker here.

 

2015/10/24 Update 2.22 of Scripting Tracker is available

  • Actualization of the recorder module to GUI 7.40
  • Minor bug fixing

 

2015/09/05 Update 2.20 of Scripting Tracker is available

  • Add the Comparator tab, to compare screens with its elements and find differences between them easily.
  • Disable the possibility to export list of screen elements as CSV file.

 

2015/03/29 Update 2.12 of Scripting Tracker is available

  • Integration of AutoIt recorder now possible
  • Add the possibility to save a complete source file via shift and save button
  • Disable support of MiniRobot, because it has no relevance
  • Minor bug fixing

 

Comments are welcome.

 

Cheers

Stefan

Viewing all 100 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>