Skip to Content

How to Build an HTA/HTML UI to Code and Execute ABAP Reports

A longer time ago I introduced CCo (COM Connector) here. Later I presented here the possibility how to program and run an ABAP Report with the scripting language VBScript and CCo. Here is now a development with the same possibility and additional an UI to code the ABAP report. It is a hypertext application.



      Execute an ABAP Report

    <hta:application applicationname="ABAPReport" id="ABAPReport"
      singleinstance="yes" border="thick" borderStyle="sunken" 
      version="1.0" />

    <script language="VBScript">

        Option Explicit

        Const RFC_OK = 0

        Sub ABAPExec()

            Dim SAP, hRFC, rc, hFuncDesc, hFunc, ABAP, i, hRow, hTable
            Dim RowCount, charBuffer, Result

          document.Output.Result.value = ""

          Set SAP = CreateObject("COMNWRFC")
          If Not IsObject(SAP) Then
            Exit Sub
          End If

          hRFC = SAP.RfcOpenConnection( _
            "ASHOST=" & document.ConnParams.ASHost.value & ", "  & _
            "SYSNR=" & document.ConnParams.SysNr.value & ", " & _
            "CLIENT=" & document.ConnParams.Client.value & ", " & _
            "USER=" & document.ConnParams.User.value)
          If hRFC = 0 Then
            Set SAP = Nothing
            Exit Sub
          End If

          hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, _
          If hFuncDesc = 0 Then
            rc = SAP.RfcCloseConnection(hRFC)
            Set SAP = Nothing
            Exit Sub
          End If

          hFunc = SAP.RfcCreateFunction(hFuncDesc)
          If hFunc = 0 Then
            rc = SAP.RfcCloseConnection(hRFC)
            Set SAP = Nothing
            Exit Sub
          End If

          '-Writes the report into the PROGRAM table--------------------
            If SAP.RfcGetTable(hFunc, "PROGRAM", hTable) = RFC_OK Then
              ABAP = Split(document.ABAP.Report.value, vbCrLf)
              For i = 0 To UBound(ABAP) - 1
                If Trim(ABAP(i)) <> "" Then
                  hRow = SAP.RfcAppendNewRow(hTable)
                  rc = SAP.RfcSetChars(hRow, "LINE", ABAP(i))
                End If
            End If

          If SAP.RfcInvoke(hRFC, hFunc) = RFC_OK Then
            '-Gets the result from the WRITES table---------------------
              If SAP.RfcGetTable(hFunc, "WRITES", 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, "ZEILE", charBuffer, 256)
                  Result = Result & Trim(charBuffer) & vbCrLf
                  If i < RowCount Then
                    rc = SAP.RfcMoveToNextRow(hTable)
                  End If
                '-Shows the result in the output area-------------------
                  document.Output.Result.value = Result
              End If
          End If

          rc = SAP.RfcDestroyFunction(hFunc)
          rc = SAP.RfcCloseConnection(hRFC)
          Set SAP = Nothing

        End Sub
        Sub Window_onLoad()
          window.moveTo 25,25
          window.resizeTo 680,710
        End Sub




      Execute an ABAP Report

    <form action="ConnParams.htm" name="ConnParams">
        <input name="ASHost" type="text" size="10" maxlength="10"
        <input name="SysNr" type="text" size="2" maxlength="2"
        <input name="Client" type="text" size="3" maxlength="3"
        <input name="User" type="text" size="12" maxlength="12"

    <input type="button" value="Execute ABAP Report"
    <form action="ABAP.htm" name="ABAP">
<textarea name="Report" cols="72" rows="18" wrap="hard">

  Report zTest Line-Size 72.

  Write: 'Hello World from'.
  Write: sy-sysid.



    <form action="Output.htm" name="Output">
        <textarea name="Result" cols="72" rows="9" wrap="soft" readonly>







As you can see it is very easy to build an external editor for ABAP reports, with the possibilities of HTML and CCo.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.