FBSL in Context of JavaScript

(Share Your Knowledge)

FBSL in Context of JavaScript

Unread postby Stefan Schnell » Wed Nov 12, 2014 7:41 am

Hello community,

I presented here a possibility to use FBSL inside ABAP, the SAP programming language. On the same way you can use FBSL inside HTML with JavaScript in Microsoft Internet Explorer browser.

Here an example:
Code: Select all
<!doctype html>

<html>

  <head>

    <title>
      FBSL test
    </title>

    <script id="FBSLScript" type="text/plain">
//-Begin----------------------------------------------------------------

  //-Directives---------------------------------------------------------
    #Option Strict
    #AppType GUI

  //-Includes-----------------------------------------------------------
    #Include <Include\Windows.inc>

  //-Sub RC-------------------------------------------------------------
    Sub RC(ByVal FileMapName As String, ByVal RetCode As String)

      //-Variables------------------------------------------------------
        Dim hMMF As Long
        Dim Buffer As Long
        Dim Temp As String
       
      hMMF = OpenFileMapping(FILE_MAP_ALL_ACCESS, 0, FileMapName)
      If hMMF Then
        Buffer = MapViewOfFile(hMMF, FILE_MAP_ALL_ACCESS, 0, 0, 0)
        If Buffer Then
          Poke(Buffer, RetCode)
          UnmapViewOffile(Buffer)
        End If
        CloseHandle(hMMF)
      End If

    End Sub

  //-Main---------------------------------------------------------------
    Sub Main()

      //-Variables------------------------------------------------------
        Dim FileMapName = "Map001"

      RC(FileMapName, MsgBox(0, "Is this cool?", "FBSL Question", _
        MB_YESNO))

    End Sub

//-End------------------------------------------------------------------
    </script>

    <script type="text/javascript">

    //-Sub RunFBSL------------------------------------------------------
      function RunFBSL(FBSLScriptName, FBSLFileName, FileMapName) {

        //-Variables----------------------------------------------------
          var oScriptX, hFileMap, rc, rcStr;

        //-Main---------------------------------------------------------
          if (navigator.appName == 'Microsoft Internet Explorer') {
          //if (window.ActiveXObject) {

            try {

              oScriptX = new ActiveXObject("ScriptX");
              if (typeof(oScriptX) == 'object') {

                oScriptX.ExtractFbslExe();
                oScriptX.ExtractFbslWinInc();

                hFileMap = oScriptX.FileMapCreate(FileMapName, 4);
                if (hFileMap != 0) {

                  oScriptX.WriteFile(FBSLFileName,
                    document.getElementById(FBSLScriptName).text);
                  rc = oScriptX.Shell("Fbsl.exe", FBSLFileName, 1, 1);
                  rcStr = oScriptX.FileMapRead(FileMapName, 4);

                  oScriptX.DeleteFileA(FBSLFileName);
                  oScriptX.DeleteDirectory("Include");
                  oScriptX.DeleteFileA("Fbsl.exe");

                  alert(rcStr);

                  rc = oScriptX.FileMapClose(hFileMap);
                }

                oScriptX = null;
              }

            }
            catch (exc) {
              alert(exc.message);
            }
          }
          else {
            alert("Your Browser doesn't support ActiveXObject");
          }

      }

    </script>

  </head>

  <body>
    <input type="button" width="60" value="Press me"
    onclick="RunFBSL('FBSLScript', 'MsgBox.fbs', 'Map001')">
  </body>

</html>


The target idea behind this realization is to implement FBSL in the context of SAPUI5.
You can find the open source version here. OpenUI5 is an Open Source JavaScript UI library, maintained by SAP and available under the Apache 2.0 license.

Here the link to the corresponding post in the SAP Community Network (SCN), with the SAPUI5 implementation.

Enjoy it.

Cheers
Stefan
Visit my homepage
or meet me at XING or at the SCN
User avatar
Stefan Schnell
FBSL geek
FBSL geek
 
Posts: 132
Joined: Thu Aug 22, 2013 7:48 am
Location: Germany - Oberirsen

Return to FBSL v3 Tips and Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

cron