In HCP, on selecting the sapui5 application template I have created a destination for c4cODataService and also checked my connection(connection successful). My OData service URL : https://myxxxxx.crm.ondemand.com/sap/byd/odata/v1/c4codata/AccountCollection I have then created controller.js and view.js by specifying the destination path.
- Contoller.js
- sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("Table_jsui5.controller.View1", {
});
});
- sap.ui.controller("Table_jsui5.controller.View1",{
|
oDataServiceURL: "c4codataaccount/sap/byd/odata/v1/c4codata",
onInit: function() {
- this.oDataModel = new sap.ui.model.odata.ODataModel(this.oDataServiceURL);
- this.getView().setModel(this.oDataModel);
}
});
- View.js
- sap.ui.jsview("Table_jsui5.view.View1", {
getControllerName: function() {
return "Table_jsui5.controller.View1";
},
createContent: function(oController) {
var oTable = new sap.m.Table("myTab");
var oDescriptionCol = new sap.m.Column({header: new sap.m.Text({text:"ABC Classification"}) });
var oCustomerCol = new sap.m.Column({header: new sap.m.Text({text:"Customer"}) });
var oStatusCol = new sap.m.Column({header: new sap.m.Text({text:"Created By"}) });
var oDueDateCol = new sap.m.Column({header: new sap.m.Text({text:"Status"}) });
var oAssignedCol = new sap.m.Column({header: new sap.m.Text({text:"Created On"}) });
- oTable.addColumn(oDescriptionCol).addColumn(oCustomerCol).addColumn(oStatusCol).addColumn(oDueDateCol).addColumn(oAssignedCol);
var oDescription = new sap.m.Text({text: "{ABCClassificationCodeText}"});
var oCustomerName = new sap.m.Text({text: "{AccountFormattedName}"});
var oStatus = new sap.m.Text({text: "{CreatedBy}"});
var oCompletionDue = new sap.m.Text({text: "{StatusCodeText}"});
var oAssignedTo = new sap.m.Text({text: "{CreatedOn}"});
var oRow = new sap.m.ColumnListItem();
- oRow.addCell(oDescription).addCell(oCustomerName).addCell(oStatus).addCell(oCompletionDue).addCell(oAssignedTo);
- oTable.bindItems("/AccountCollection", oRow);
|
//console.log ("Hello");
var oPage = new sap.m.Page({
title: "{i18n>title}",
content: [oTable]
});
var app = new sap.m.App("myApp", {
initialPage: "oPage"
});
app.addPage(oPage);
return app;
}
});
neo-app.json
{
"welcomeFile": "/webapp/index.html",
"routes": [
{
"path": "/c4codataaccount",
|
"target": {
"type": "destination",
"name": "c4codataaccount",
"entryPath": "/c4codataaccount"
}
},
{
"path": "/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources"
},
"description": "SAPUI5 Resources"
},
{
"path": "/test-resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources"
},
"description": "SAPUI5 Test Resources"
}
],
"sendWelcomeFileRedirect": true
}
And no changes in index.html file.. I have attached the screenshot of my destination that i have created.
On running this I get NO DATA in my table and I get these errors: (attached screenshot)
What is the mistake I’m doing? Please help as soon as possible.
ALTERNATE SOLUTION WHICH I TRIED :
SAPUI5 – Specify Direct URL
Similarly i have created sapui5 application in HCP without using the destination path by specifying the OData service URL directly. In this also I’m getting NO DATA in my table and these following errors : (screenshot)
Code :
- Controller.js
- sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("FinalTable.controller.View1", {
onInit: function() {
var sUrl = "proxy/https://myxxxxxx.crm.ondemand.com/sap/byd/odata/v1/c4codata/AccountCollection";
var oModel = new sap.ui.model.json.JSONModel(sUrl);//,false,"xxxxx","zzzzzz");
//SOP Suppress
// var domainstring = "document.domain";
// domainstring = "*.com";
// "Access-Control-Allow-Origin: *.local.com";
// "Access-Control-Allow-Headers: X-KEY";
//var oModel = new sap.ui.model.odata.ODataModel("http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/",false,"GW@ESW","ESW4GW");
//var oModel = new sap.ui.model.odata.ODataModel("proxy/https://myxxxxxx.crm.ondemand.com/sap/byd/odata/v1/c4codata/AccountCollection",false,"[username]","[password]");
sap.ui.getCore().setModel(oModel);
this.getView().setModel(oModel);
}
});
});
- View.js
- sap.ui.jsview("FinalTable.view.View1", {
getControllerName: function() {
return "FinalTable.controller.View1";
},
createContent: function(oController) {
var oTable = new sap.m.Table("idPrdList", {
inset : true,
headerText : "List of Sales Order",
headerDesign : sap.m.ListHeaderDesign.Standard,
mode : sap.m.ListMode.None,
includeItemInSelection : false
});
var col1 = new sap.m.Column("col1",{header: new sap.m.Label({text:"ABC Classification"})});
oTable.addColumn(col1);
var col2 = new sap.m.Column("col2",{header: new sap.m.Label({text:"Customer"})});
oTable.addColumn(col2);
var col3 = new sap.m.Column("col3",{header: new sap.m.Label({text:"Created By"})});
oTable.addColumn(col3);
var col4 = new sap.m.Column("col4",{header: new sap.m.Label({text:"Status"})});
oTable.addColumn(col4);
var col5 = new sap.m.Column("col5",{header: new sap.m.Label({text:"Created On"})});
oTable.addColumn(col5);
//create the ColumnListItem and bind the aggregation to the table
var colItems = new sap.m.ColumnListItem("colItems",{type:"Active"});
oTable.bindAggregation("items","/AccountCollection",colItems);
var txtNAME = new sap.m.Text("txtNAME",{text:"{ABCClassificationCodeText}"});
colItems.addCell(txtNAME);
var txtNAME2 = new sap.m.Text("txtNAME2",{text:"{AccountID}"});
colItems.addCell(txtNAME2);
var txtNAME3 = new sap.m.Text("txtNAME3",{text:"{CreatedBy}"});
colItems.addCell(txtNAME3);
var txtNAME4 = new sap.m.Text("txtNAME4",{text:"{StatusCodeText}"});
colItems.addCell(txtNAME4);
var txtNAME5 = new sap.m.Text("txtNAME5",{text:"{CreatedOn}"});
colItems.addCell(txtNAME5);
var oPage = new sap.m.Page({
title: "{i18n>title}",
content: [oTable]
});
var app = new sap.m.App("myApp", {
initialPage: "oPage"
});
app.addPage(oPage);
return app;
}
});