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.

To use FBSL inside ABAP I build an ActiveX library, called ScriptX. ScriptX contains FBSLand 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'.
        Call Function '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'.

        Call Method cl_gui_frontend_services=>get_sapgui_workdir
          Changing SAPWORKDIR = WorkDir Exceptions Others = 1.
        Concatenate '#Include "' WorkDir '\Windows.inc"' 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.
          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.

 

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

To report this post you need to login first.

4 Comments

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

  1. 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,

    (0) 
    1. Stefan Schnell 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.

      Cheers

      Stefan

      (0) 
      1. solen dogan

        Stefan

        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

        (0) 
        1. Stefan Schnell 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 fbslx.zip 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.

          Cheers

          Stefan

          (0) 

Leave a Reply