ODataサービスを使用してバックエンドABAPシステムに接続しようとしていますが、スクリーンショットに示すようにエラーが発生しています。ODataサービスに接続できません
ライブラリ-preload.js:522キャッチされない例外TypeError:プロパティを読み取ることができません。(...)未定義の '読み取り'
ここでは、さまざまなファイルのコードです:
ネオアプリは、 .json:
{
"path": "/DB7",
"target": {
"type": "destination",
"name": "DB7"
},
"description": "DB7"
}
Component.js
init: function() { var oModel = new sap.ui.model.odata.v2.ODataModel(this.getMetadata().getConfig().serviceUrl);
this.setModel(oModel,"data");
}
manifest.jsonを
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "com.abc.cup",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.32.0"
},
"dataSources": {
"invoiceRemote": {
"uri": "/destinations/DB7/sap/opu/odata/ATSH/UI5_DISPLAY_SRV/",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "favicon.ico",
"phone": "",
"[email protected]": "",
"tablet": "",
"[email protected]": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": ["sap_hcb", "sap_bluecrystal"]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "com.abc.cop.view.View1",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"":{
"dataSource": "invoiceRemote",
"settings":{}
},
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "com.abc.cop.i18n.i18n"
}
}
},
"resources": {
"css": [{
"uri": "css/style.css"
}]
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewPath": "com.abc.cop.view",
"controlId": "appId",
"controlAggregation": "pages",
"transition": "fade"
},
"routes": [{
"name": "main",
"pattern": "",
"target": ["initialScreen"]
}, {
"name": "moreDetails",
"pattern": "moreDetails",
"target": ["moreDetails"],
"greedy": true
}
],
"targets": {
"main": {
"viewType": "XML",
"transition": "slide",
"viewName": "View1",
"viewId": "view1",
"viewLevel": 1
},
"moreDetails": {
"viewType": "XML",
"transition": "fade",
"viewName": "View2",
"viewId": "view2",
"clearAggregation": true,
"viewLevel": 2,
"controlId": "appId"
},
"initialScreen": {
"viewType": "XML",
"transition": "fade",
"clearAggregation": true,
"viewName": "View3",
"viewId": "view3"
}
}
}
}
}
Controller.js
onBeforeRendering: function() {
var oModell = new sap.ui.model.odata.ODataModel(
"https://webidetesting3386376-p1942296689trial.dispatcher.hanatrial.ondemand.com/destinations/DB7/sap/opu/odata/ATSH/UI5_DISPLAY_SRV/"
);
//var oJSONModel = new sap.ui.model.json.JSONModel();
oModell.read("SY_INFOSet(Customer='ABC',Sysid='DB7')", null, null, true, function(oData, oResponse) {
alert("Read successful: " + JSON.stringify(oData));
this.getView().setModel(oModell, "jsonData");
//var oModel22 = new sap.ui.model.json.JSONModel(oData);
//sap.ui.getCore().setModel(oModel22, "jsonData");
}, function() {
alert("Read failed");
});
},
View.xml
<ObjectHeader class="HeaderObjectwidth" id="objectHeader" title="{i18n>systemId} - {SYS_INFOSet/Sysid}" number="{i18n>numUsers} {SYS_INFO/Customer}" numberUnit="{i18n>versionId} {SYS_INFO/Sysid}">
<attributes>
<ObjectAttribute title="{i18n>custName}" text="{jsonData>/FILE_UPD_UI5Set/Customer}"/>
<ObjectAttribute title="{i18n>osDetails}" text="{jsonData>Customer}"/>
<ObjectAttribute title="{i18n>dbDetails}" text="{jsonData>/Value}"/>
</attributes>
</ObjectHeader>
マニフェストから 'sap.ui5'名前空間の 'models'を貼り付けることはできますか? –
...詳細が必要です。 'this.getView()....'はどこですか?初期化メソッドで?ここでの問題は 'getModel'は何も返さないため、何らかの理由でビューに関連するモデルがありません。 –
@RahulBhardwaj私はmanifest.jsonからモデルを追加しました – sky