SELECT
NON EMPTY
{ [48CSWO6CA6TXXHDU2Q35OLJW0].Members }
ON COLUMNS,
NON EMPTY
{ [0D_FC_COUN 0D_FC_COUN_H001].Members }
DIMENSION PROPERTIES
LEVEL_NUMBER
ON ROWS
FROM
[0D_FC_C02/0D_FC_AE_EOIBV_Q001]
var _sRequest = `
<Execute>
<Command>
<Statement>
${_sMdx}
</Statement>
<Properties>
<PropertyList>
<Format></Format>
</PropertyList>
</Properties>
</Command>
</Execute>`;
$.post("/sap/bw/xml/soap/xmla/Execute",_sRequest , _fProcessData);
var _oRoot = oData.querySelector("ExecuteResponse>return>root")
if(!_oRoot){
debugger;
var _sError =
oData.querySelector("Error")?.getAttribute("Description") ||
"undefined Error";
_fReject(_sError)
return;
}
_ColumnNodes = _oRoot.querySelectorAll("Axes>[name='Axis0']>Tuples>Tuple");
_RowNodes = _oRoot.querySelectorAll("Axes>[name='Axis1']>Tuples>Tuple");
_DataNodes = _oRoot.querySelectorAll("CellData>Cell");
_RowNodes.forEach(pRow=>{
let _oMemberNodes = pRow.querySelectorAll("Member")
let _aRow = [];
_oMemberNodes.forEach(pMember=>{
let _sName = pMember.attributes[0].value.replace(/\s+/g,"_");
_aRow[_sName] = pMember.querySelector("Caption").textContent;
pMember.querySelectorAll(":nth-child(n+6)")
.forEach(pProperty=>_aRow[_sName+pProperty.nodeName] = pProperty.textContent);
})
_aRowName.push(_aRow);
});
_ColumnNodes.forEach(pRow=>{
let _oMemberNodes = pRow.querySelectorAll("Member")
_oMemberNodes.forEach(pMember=>{
_aColName.push(pMember.querySelector("Caption").textContent);
})
});
_iCntRow = _aRowName.length;
_iCntCol = _aColName.length;
_DataNodes.forEach((pData,pIndex)=>{
let _sValue = pData.querySelector("Cell>Value").textContent;
let _iRow = Math.trunc(pIndex / _iCntCol)
let _iCol = pIndex % _iCntCol;
_aRowName[_iRow][_aColName[_iCol]] = _sValue
});
this.getMdxData(this.getMdx())
.then(aData=>{
this.getView().getModel("viewModel").setProperty("/mdxData",aData);
})
.catch((oError)=>{
debugger
})
File: zxmla/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<title>XMLA-Test</title>
<script
id="sap-ui-bootstrap"
src="resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"
data-sap-ui-resourceroots='{
"zxmla": "./"
}' >
</script>
<script>
sap.ui.getCore().attachInit(function () {
sap.ui.xmlview({
viewName : "zxmla.Test"
}).placeAt("content");
});
</script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>
File: zxmla/Test.view.xml
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
controllerName="zxmla.Test">
<Table id="idProductsTable" items="{viewModel>/mdxData}">
<headerToolbar>
<Toolbar>
<content>
<Title text="Products" level="H2"/>
<ToolbarSpacer />
<Button text="Go" press=".onPress"/>
</content>
</Toolbar>
</headerToolbar>
<columns>
<Column><Text text="Level" /></Column>
<Column><Text text="Land" /></Column>
<Column><Text text="konsolidiertes Netto" /></Column>
<Column><Text text="netto Umsatz" /></Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{viewModel>0D_FC_COUN_0D_FC_COUN_H001LEVEL_NUMBER}" />
<Text text="{viewModel>0D_FC_COUN_0D_FC_COUN_H001}" />
<Text text="{viewModel>Konsolidierter Netto}" />
<Text text="{viewModel>Nettoumsatz}" />
</cells>
</ColumnListItem>
</items>
</Table>
</core:View>
File: zxmla/Test.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel"
], function(Controller, JSONModel) {
"use strict";
return Controller.extend("zxmla.Test", {
onInit: function() {
var _oModel = new JSONModel({mdxData: []});
this.getView().setModel(_oModel, "viewModel");
},
onPress: function(oEvent){
this.getMdxData(this.getMdx())
.then(aData=>{
debugger
this.getView().getModel("viewModel").setProperty("/mdxData",aData);
})
.catch((oError)=>{
debugger
})
},
getMdxData: function(sMdx){
var _fResolve, _fReject,
_oPromise = new Promise((resolve,reject)=>{
_fResolve = resolve;
_fReject = reject;
});
var _sMdx = this.getMdx();
var _sRequest = `
<Execute>
<Command>
<Statement>
${_sMdx}
</Statement>
<Properties>
<PropertyList>
<Format></Format>
</PropertyList>
</Properties>
</Command>
</Execute>`;
var _fProcessData = function(oData, sStatus){
var _oRoot = oData.querySelector("ExecuteResponse>return>root")
if(!_oRoot){
debugger;
var _sError =
oData.querySelector("Error")?.getAttribute("Description") ||
"undefined Error";
_fReject(_sError)
return;
}
var _aColName = [], _iCntRow = 0, _iCntCol = 0;
var _aRowName = []
var _ColumnNodes =
_oRoot.querySelectorAll("Axes>[name='Axis0']>Tuples>Tuple")
var _RowNodes =
_oRoot.querySelectorAll("Axes>[name='Axis1']>Tuples>Tuple")
var _DataNodes = _oRoot.querySelectorAll("CellData>Cell")
_RowNodes.forEach(pRow=>{
let _oMemberNodes = pRow.querySelectorAll("Member")
let _aRow = [];
_oMemberNodes.forEach(pMember=>{
let _sName = pMember.attributes[0].value.replace(/\s+/g,"_");
_aRow[_sName] = pMember.querySelector("Caption").textContent;
pMember.querySelectorAll(":nth-child(n+6)")
.forEach(pProperty=>_aRow[_sName+pProperty.nodeName] = pProperty.textContent);
})
_aRowName.push(_aRow);
});
_ColumnNodes.forEach(pRow=>{
let _oMemberNodes = pRow.querySelectorAll("Member")
_oMemberNodes.forEach(pMember=>{
_aColName.push(pMember.querySelector("Caption").textContent);
})
});
_iCntRow = _aRowName.length;
_iCntCol = _aColName.length;
_DataNodes.forEach((pData,pIndex)=>{
let _sValue = pData.querySelector("Cell>Value").textContent;
let _iRow = Math.trunc(pIndex / _iCntCol)
let _iCol = pIndex % _iCntCol;
_aRowName[_iRow][_aColName[_iCol]] = _sValue
});
debugger
_fResolve(_aRowName)
// check _aRowName
};
$.post("/sap/bw/xml/soap/xmla/Execute",_sRequest , _fProcessData);
return _oPromise
},
getMdx: function(){
var _sMdx =
`SELECT
NON EMPTY
{ [48CSWO6CA6TXXHDU2Q35OLJW0].Members }
ON COLUMNS,
NON EMPTY
{ [0D_FC_COUN 0D_FC_COUN_H001].Members }
DIMENSION PROPERTIES
LEVEL_NUMBER
ON ROWS
FROM
[0D_FC_C02/0D_FC_AE_EOIBV_Q001]`
return _sMdx;
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 | |
3 |