<!doctype html>
<html>
<head>
<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”
id=”sap-ui-bootstrap”
data-sap-ui-libs=”sap.ui.commons, sap.ui.table”
data-sap-ui-theme=”sap_bluecrystal”>
</script>
<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,
location.pathname.lastIndexOf(“/”))+”/”;
pathName = pathName.slice(1);
wsh.run(“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();
oLabel.setText(Text);
oTemplate = new sap.ui.commons.TextView();
oTemplate.bindProperty(“text”, Text);
oColumn = new sap.ui.table.Column();
oColumn.setLabel(oLabel);
oColumn.setTemplate(oTemplate);
oColumn.setWidth(Width);
return oColumn;
}
function main() {
var oModel, oTable;
getData(“SFLIGHT”);
oModel = new sap.ui.model.json.JSONModel();
oModel.loadData(“SFLIGHT.json”);
oTable = new sap.ui.table.Table();
oTable.setTitle(“Table SFLIGHT”);
oTable.setVisibleRowCount(15);
oTable.setFirstVisibleRow(0);
//-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”));
oTable.setModel(oModel);
oTable.bindRows(“/SFLIGHT”);
oTable.placeAt(“content”)
}
</script>
</head>
<body class=”sapUiBody” role=”application” onLoad=”main()”>
<div id=”content” />
</body>
</html>
'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Constants-----------------------------------------------------------
Const RFC_OK = 0
Const ForWriting = 2
'-Sub getData---------------------------------------------------------
Sub getData(tableName, pathName)
'-Variables-------------------------------------------------------
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
Next
'-Write JSON file-------------------------------------
Set FSO = CreateObject("Scripting.FileSystemObject")
If IsObject(FSO) Then
Set F = FSO.OpenTextFile(pathName & tableName & _
".json", ForWriting, True)
F.Write charFile
F.Close
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
'-Main----------------------------------------------------------------
getData WScript.Arguments.Item(0), WScript.Arguments.Item(1)
'-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |