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 can find FBSL here.
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.
You can find FBSLX here.
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 architecture map of FBSL in the context of SAP application server.
- Here an ABAP code, how to use a drop zone.
- Here a FBSL code, how to create an SAP server application.
Update 2014/03/01
- Release candidate 2 of FBSL 3.5 here available.
- An actualized version of FBSLX is also here available.
Here another example which shows a Mandelbrot benchmark test with FbslX and FBSL inside ABAP.
Comments are welcome.
Enjoy it.
Cheers
Stefan


