Hello community,
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.
<html> <head> <title> Execute an ABAP Report </title> <hta:application applicationname="ABAPReport" id="ABAPReport" singleinstance="yes" border="thick" borderStyle="sunken" version="1.0" /> <script language="VBScript"> '-Directives------------------------------------------------------ Option Explicit '-Constants------------------------------------------------------- Const RFC_OK = 0 '-ABAPExec-------------------------------------------------------- Sub ABAPExec() '-Variables--------------------------------------------------- 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, _ "RFC_ABAP_INSTALL_AND_RUN") 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 Next 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 Next '-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 '-onLoad---------------------------------------------------------- Sub Window_onLoad() window.moveTo 25,25 window.resizeTo 680,710 End Sub </script> </head> <body> <h1> Execute an ABAP Report </h1> <form action="ConnParams.htm" name="ConnParams"> <p> ASHost: <input name="ASHost" type="text" size="10" maxlength="10" value="ABAP"> SysNr.: <input name="SysNr" type="text" size="2" maxlength="2" value="00"> Client: <input name="Client" type="text" size="3" maxlength="3" value="001"> User: <input name="User" type="text" size="12" maxlength="12" value="BCUSER"> </p> </form> <input type="button" value="Execute ABAP Report" onClick='ABAPExec()'> <form action="ABAP.htm" name="ABAP"> <p><textarea name="Report" cols="72" rows="18" wrap="hard"> "-Begin----------------------------------------------------------------- Report zTest Line-Size 72. Write: 'Hello World from'. Write: sy-sysid. "-End-------------------------------------------------------------------</textarea> </p> </form> <form action="Output.htm" name="Output"> <p> <textarea name="Result" cols="72" rows="9" wrap="soft" readonly> </textarea> </p> </form> </body> </html>
As you can see it is very easy to build an external editor for ABAP reports, with the possibilities of HTML and CCo.
Cheers
Stefan