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

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

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. FBSL is not longer available anymore.

To use FBSL inside ABAP I build an ActiveX library, called ScriptX. ScriptX contains FBSL and 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:

  Program ZFBSL.

      Constants CrLf(2) Type c Value %_CR_LF.

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

      Define _.
        Concatenate Buffer &1 CrLf Into Buffer.

      Define Flush.
        Call Function 'AC_SYSTEM_FLUSH' Exceptions Others = 1.

      Create Object oFBSL 'FbslX'.

      If sy-subrc <> 0 Or  oFBSL-Handle = 0 Or oFBSL-Type <> 'OLE2'.
        Call Function 'ZFBSL_WININC'.
        Call Function 'ZFBSL_DLL'.
        Call Function 'ZFBSLX'.
        Create Object oFBSL 'FbslX'.

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

        Call Method cl_gui_frontend_services=>get_sapgui_workdir
          Changing SAPWORKDIR = WorkDir Exceptions Others = 1.
        Concatenate '#Include "' WorkDir '\"' Into WinInc.

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

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

        Write: RetVal.

        Free Object oFBSL.



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 example how to use C code inside ABAP.




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



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo solen dogan
      solen dogan

      Hello Stefan,

      that seems interesting, i never heard this FBLS before.

      So how does abap links to the scripting code.

      Do you write the script and store it as dll on the server

      then you call it from Abap?

      is that the way it works,

      Author's profile photo Stefan Schnell
      Stefan Schnell
      Blog Post Author

      Hello Solen,

      thanks for your reply.

      The FBSL and the FBSLX library are stored as ABAP function modules (FM). If you call this FMs, it will install and register on the presentation server automatically. Now it is necessary to define the FBSL script code inside your ABAP program and store this code in a string variable. Then the code is transmitted to the and executed from the library on the presentation server, via ExecuteScriptBuffer. The whole processis is not explicitly perceived by the user. Everything is done in the user space, without explicit administrator rights.



      Author's profile photo solen dogan
      solen dogan


      Thanks for your reply, its quite interesting how it works

      I wıill like to try it sure

      İ tried to call the fbsl library, thru se37

      what are the function modules to call?

      i couldnt find any fm s with fbsl

      Author's profile photo Stefan Schnell
      Stefan Schnell
      Blog Post Author

      Hello Solen,

      thanks for your interest.

      2014/03/18 - Hint: The following description is for the older version of FBSLX for FBSL 3.4. The actual version of FBSLX for FBSL 3.5 implements all necessary files.

      Open the file and choose the directory ABAP. Inside this directory you find

      1. zFbslX.abap - this FM contains FbslX.dll
      2. zFbsl_dll.abap - this FM contains Fbsl.dll
      3. zFbsl_exe.abap - this FM contains Fbsl.exe
      4. zFbsl_Tiny.abap - this FM contains Fbsl_Tiny.exe

      After the import of this FMs in your SAP system you can use the example reports from the same directory. They installs and registers the libraries themselves.

      Let us know the results.