Skip to Content
Technical Articles
Author's profile photo Stefan Schnell

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

Freestyle BASIC Script Language (FBSL) is a true multitalent, but it is unfortunately not more available. It is possible to use it inside ABAP and to use SAP GUI Scripting with it, as the example here shows. It is only a simple logon, but it shows how to use FBSL in this case. This example has now only historical museum character.

//-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.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sayuti Azmi
      Sayuti Azmi

      interesting.. as always. 🙂