Skip to Content
0

SAPUI5 VIzChart

Feb 01, 2017 at 01:48 PM

86

avatar image

Hi,

I am trying to get data to my Viz Chart.

My code looks like this:

First getting the data from oData (testing now with hard coded value) and putting it to json format:

var oVizFrame = this.oView.byId("idVizFrame");
var oVizModel = new sap.ui.model.json.JSONModel();
var strUrl = "http://xxxxxxxxxxxxxxx/sap/opu/odata/sap/ZOC_SRV/SalesOrderHdrSet('60008432')/SalesOrderToItems/?$format=json";
oVizModel.loadData(strUrl);
var oDataset = new sap.viz.ui5.data.FlattenedDataset({

dimensions: [{
name  : 'Quantity',
value : "{OrderedQty}"}],

measures : [{
name : 'Value',
value : '{Value}'}],

data : {
path : "/SalesOrderItemSet"
}
});

When I look at oVizModel I do not see the data in the debugger, that is the first problem. The the second question, should I rather use oData model instead of json and if so, how?

Thanks,

Tim

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Suriyanarayanan Balamurugan
Feb 06, 2017 at 06:01 AM
0

Hi Tim,

For your first question - Since your json model gives the above json content, you have to mention your data path as "/d/results" instead of "/SalesOrderItemSet". The data will be displayed.

var oDataset =newsap.viz.ui5.data.FlattenedDataset({

dimensions:[{name:'Quantity',value:"{OrderedQty}"}],

measures :[{name:'Value',value:'{Value}'}],data:{
path :"/d/results"}});

For second question - You can either you json model or Odata model depends on you use case.

Thanks,

Surya

Share
10 |10000 characters needed characters left characters exceeded
Tim Krause Feb 01, 2017 at 02:31 PM
0

In addition to my above code example, when I check the service with the same string

/sap/opu/odata/sap/ZOC_SRV/SalesOrderHdrSet('60008432')/SalesOrderToItems/?$format=json

I get this result:

{
 "d" : {
 "results" : [
 {
 "__metadata" : {
 "id" : "xxxxxxxxxxx/sap/opu/odata/sap/ZOC_SRV/SalesOrderItemSet(Vbeln='60008432',Posnr='000010')",
 "uri" : "xxxxxxxxxxx/sap/opu/odata/sap/ZOC_SRV/SalesOrderItemSet(Vbeln='60008432',Posnr='000010')",
 "type" : "ZOC_SRV.SalesOrderItem"
 },
 "Matnr" : "C001.90001",
 "Vbeln" : "60008432",
 "ZGrammage" : "200",
 "Maktx" : "Performa Cream",
 "Posnr" : "000010",
 "ZReelWidth" : "1100",
 "OrderedQty" : "0.000",
 "PlannedProd" : "0.000",
 "ZReelDiameter" : "1400",
 "ActualProd" : "0.000",
 "ZCoreDiameter" : "305",
 "StockQty" : "0.000",
 "PlannedDel" : "0.000",
 "ActualDel" : "0.000",
 "InvoicedQty" : "0.000",
 "ProdStatus" : "",
 "FullProdStatus" : "",
 "Edatu" : null,
 "ZseDelDate" : null,
 "Mbdat" : null
 }
Share
10 |10000 characters needed characters left characters exceeded