Skip to Content
0

Not able to connect to Bex Query with SAP UI5 app

Oct 26, 2017 at 04:09 AM

29

avatar image
Former Member

Hi Experts,

I am very new to Fiori and UI5.

I am able to generate a simple fiori chart with JSON data defined inside my View1.controller.js. But when I am trying to connect to my Bex query and display it as a chart, I am unable to do so.

I have 3 items basically

  1. Index.html
  2. XML view
  3. Controller for XML view

Index.html looks like

<!DOCTYPE HTML>
<html>

	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta charset="UTF-8">

		<title>helloworld6</title>

		<script id="sap-ui-bootstrap"
			src="../../resources/sap-ui-core.js"
			data-sap-ui-libs="sap.m"
			data-sap-ui-theme="sap_belize"
			data-sap-ui-compatVersion="edge"
			data-sap-ui-resourceroots='{"helloworld6": ""}'>
		</script>

		<link rel="stylesheet" type="text/css" href="css/style.css">

			<script>
			sap.ui.getCore().attachInit(function() {
			sap.ui.xmlview({
				viewName : "helloworld6.view.View1"
			}).placeAt("content");
			});
		</script>
	</head>

	<body class="sapUiBody" id="content">
	</body>

</html>

XML view look like

<mvc:View controllerName="helloworld6.controller.View1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
  xmlns:viz="sap.viz.ui5.controls" 
 xmlns="sap.m">
<Toolbar>
	<ToolbarSpacer/>
<Title text="SEPOS APP"/>
	<ToolbarSpacer/>
 <Button icon="sap-icon://action" press="onPress" ariaLabelledBy="actionButtonLabel"/>	
</Toolbar>
	<viz:VizFrame xmlns="sap.viz" id="idcolumn" width="100%">
		</viz:VizFrame>	
</mvc:View>

And the View1.controller.js looks like

sap.ui.define([
	"sap/m/MessageToast","sap/ui/core/mvc/Controller"
], function(MessageToast,Controller) {
	"use strict";
	var PageController = Controller.extend("helloworld6.controller.View1",{
		
	onInit: function(){
		//                1.Get the id of the VizFrame
	var oVizFrame = this.getView().byId("idcolumn");
	var oDataSetBex = new sap.viz.ui5.data.FlattenedDataset({
		'dimensions' : [{
			'name' : 'Month and Year',
			'value': "{A0CALWEEK}"
		}],
		'measures':[{
			'name':'Sales',
			'value':'{A00O2TPJXEBUT4F4UBQXI2U4EQ}'
		}],
		'data': {
			'path':"/OE_SD_FIORI_APPResults?$select=A0CALWEEK,A00O2TPJXEBUT4F4UBQXI2U4EQ&$top=3"
		}
	});
var feedPrimaryValues4 = new sap.viz.ui5.controls.common.feeds.FeedItem({
	      'uid' : "primaryValues",
	      'type' : "Measure",
	      'values' : [ "Sales" ]
	    });
var feedAxisLabels4 = new sap.viz.ui5.controls.common.feeds.FeedItem({
	      'uid' : "axisLabels",
	      'type' : "Dimension",
	      'values' :  ["Month and Year"]
	    });
oVizFrame.setDataSet(oDataSetBex);
var oDataBExModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZODSP_SEPOS_DATA_SRV/");
oVizFrame.setModel(oDataBExModel);
oVizFrame.addFeed(feedPrimaryValues4);
oVizFrame.addFeed(feedAxisLabels4);
oVizFrame.setVizType('bar');
},
onPress:function(){
	MessageToast.show("Button Pressed");
}
});
return PageController;
});

Am I missing something? Any help is appreciated.

Regards,

Arpan

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

0 Answers