Skip to Content

Hello community,

I describe here how to extend your copy of the function module (FM) RFC_READ_TABLE to get the result also in JSON format. On this way you have the tiny possibility to get a little bit the feeling of OData via SAP Gateway interface, e.g. if you are using an older version of an SAP AS.

Here I describe how to call a VBScript from JavaScript with IE 11 in edge mode.

With this descriptions and the COM Connector (CCo) is it now possible to realize a solution in the UI5 context. We will start with the html file:

<!doctype html>



    <title>Table SFLIGHT</title>

    <meta http-equiv=”Content-Type” content=”text/html” />

    <meta charset=”ISO-8859-1″ />

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge” />

    <script src=”resources/sap-ui-core.js”


      data-sap-ui-libs=”sap.ui.commons, sap.ui.table”



    <script language=”JavaScript”>

      function getData(TableName) {


          var wsh, pathName;

        if (“ActiveXObject” in window) {

          wsh = new ActiveXObject(“WScript.Shell”);

          if (typeof(wsh) == ‘object’) {

            pathName = location.pathname.substr(0,


            pathName = pathName.slice(1);

  “wscript.exe \”” + pathName +

              “ReadTableJSON.vbs\” ” + TableName + ” \”” + pathName +

              “\””, 1, true);

            wsh = null;



        else {

          alert(“Your Browser doesn’t support ActiveXObject”);



      function Column(Text, Width) {


          var oLabel, oTemplate, oColumn;

        oLabel = new sap.ui.commons.Label();


        oTemplate = new sap.ui.commons.TextView();

        oTemplate.bindProperty(“text”, Text);

        oColumn = new sap.ui.table.Column();




        return oColumn;


      function main() {


          var oModel, oTable;


        oModel = new sap.ui.model.json.JSONModel();


        oTable = new sap.ui.table.Table();

        oTable.setTitle(“Table SFLIGHT”);



        //-Add the columns———————————————-

          oTable.addColumn(Column(“CARRID”, “35px”));

          oTable.addColumn(Column(“CONNID”, “35px”));

          oTable.addColumn(Column(“FLDATE”, “50px”));

          oTable.addColumn(Column(“PRICE”, “50px”));

          oTable.addColumn(Column(“CURRENCY”, “50px”));

          oTable.addColumn(Column(“PLANETYPE”, “50px”));







  <body class=”sapUiBody” role=”application” onLoad=”main()”>

    <div id=”content” />



As you can see it is not really the known standard. The main function gets at first the data as local JSON file via our copy of RFC_READ_TABLE from the table SFLIGHT. It loads the data, creates the table and adds the columns via an own function. I use only the set and get methods, it is better readable I think. Here now the VBScript file to get the data in JSON format:



    Option Explicit


    Const RFC_OK = 0

    Const ForWriting = 2

  ‘-Sub getData———————————————————

    Sub getData(tableName, pathName)


        Dim SAP, hRFC, rc, hFuncDesc, hFunc, hTable, RowCount, i, hRow

        Dim charBuffer, charFile, FSO, F

      Set SAP = CreateObject(“COMNWRFC”)

      If IsObject(SAP) Then

        hRFC = SAP.RfcOpenConnection(“ASHOST=ABAP, SYSNR=00, ” & _

          “CLIENT=000, USER=BCUSER”)

        If hRFC Then

          hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, “Z_RFC_READ_TABLE_JSON”)

          If hFuncDesc Then

            hFunc = SAP.RfcCreateFunction(hFuncDesc)

            If hFunc Then

              rc = SAP.RfcSetChars(hFunc, “QUERY_TABLE”, tableName)

              rc = SAP.RfcSetChars(hFunc, “DELIMITER”, “~”)

              If SAP.RfcInvoke(hRFC, hFunc) = RFC_OK Then

                If SAP.RfcGetTable(hFunc, “DATA_JSON”, hTable) = RFC_OK Then

                  rc = SAP.RfcGetRowCount(hTable, RowCount)

                  rc = SAP.RfcMoveToFirstRow(hTable)

                  For i = 1 To RowCount

                    hRow = SAP.RfcGetCurrentRow(hTable)

                    rc = SAP.RfcGetChars(hRow, “LINE”, charBuffer, 1024)

                    charFile = charFile & RTrim(charBuffer) & vbCrLf

                    If i < RowCount Then

                      rc = SAP.RfcMoveToNextRow(hTable)

                    End If


                  ‘-Write JSON file————————————-

                    Set FSO = CreateObject(“Scripting.FileSystemObject”)

                    If IsObject(FSO) Then

                      Set F = FSO.OpenTextFile(pathName & tableName & _

                        “.json”, ForWriting, True)

                      F.Write charFile


                      Set FSO = Nothing

                    End If

                End If

              End If

            rc = SAP.RfcDestroyFunction(hFunc)

            End If

          End If

          rc = SAP.RfcCloseConnection(hRFC)

        End If

        Set SAP = Nothing

      End If

    End Sub


    getData WScript.Arguments.Item(0), WScript.Arguments.Item(1)


With this mixture of RFC libary via CCo, VBScript and JavaScript in IE 11 you can easily simulate an UI5 environment on the presentation server, without any other server. Also it is not necessary, with the modifiaction of your copy of RFC_READ_TABLE, to have the newest AS environment.


On this way you can realize a relatively lightweight solution, to simulate OData via SAP Gateway and to use it in your UI5 environment on your presentation server.

Enjoy it.



To report this post you need to login first.


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

  1. Stefan Schnell Post author

    Hello community,

    here a tiny function to validate the JSON file:

      //-function isJSON----------------------------------------------------
        function isJSON(FileName) {
            var strFile;
            url: FileName,
            type: 'get',
            async: false,
            success: function(jsonFile) {
              strFile = String(jsonFile);
          try {
          catch (event) {
            return false;
          return true;




Leave a Reply