on 2018 Nov 02 3:13 PM
Hello together,
What I want to do is:
- load a model with some data from a local json file
In the WebIde the data will be loaded correctly but when I deploy the application to the backend I'm not able to read the propertys.
The SAPUI5 Versions are:
- WebIDE: 1.56.10
- Backend: 1.52.09 (Should be newest stable Version)
I have a Json File (model/AppData.json):
{ "AddData":{ <br> "IdKunnr": "0000000035" }
}
manifest.json:
"models":{ <br> "AppData": { <br> "type": "sap.ui.model.json.JSONModel", "settings": {}, <br> "uri": "model/AppData.json", "preload": true }
}
In a Controller I try to Access the data:
onAddItem: function (oEvent) {
var v1 = this.getView().getModel("AppData").getProperty("/AppData/IdKunnr");
...
v1 is undifined (when I test in backend - in SAP Web Ide all works fine).
When I debug the coding I can see the the model "AppData" exists but has no Content in the oData Variable.
Perhaps anybody can help me.
Best regards
Hello Uwe
Your "model" configuration seems right. but your getModel call doesnt. The model AppData is a application component, which is not visible at controller level (local scope). So, you should use getModel at the global scope, just like below:
this.getOwnerComponent().getModel("AddData");
Models defined in manifest should be called through this.getOwnerComponent().
BR
Arthur Silva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nobody - Maybe anybody from SAP.
I would also be happy if anybody would say that I couldn't use this concept in an AS ABAP FLP Application.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Thank you for your example but it is not a complete project and I don't understand why are you try to load the model - I think the framework should do this if the file is referenced in the manifest file.
Can anybody please share a complete GitHub project:
For me point 6 is very important!
My sample application will work standalone on AS ABAP but not in the Fiori Launch Pad
Best Regards
Uwe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello together,
Thank you for your response but I am not getting any working application (on AS ABAP in FLP).
Two questions:
1. Can anybody send me an link to a simple example project (maybe GitHub) which is showing data out of a json file and witch should also work on AS ABAP FLP? Maybe it is a wrong configuration in AS ABAP.
2. Is there any documentation about the differences between running Apps in Web IDE FLP and running Apps in AS ABAP FLP? Generally, json files which are defined in manifest.json should be loaded automatically. Why not on AS ABAP FLP?
Best regards
Uwe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Here's an example:
Btw, your manifest.json will be read at same time your Component.js is loaded. So no difference between ABAP and FLP.
BR
Arthur Silva
I tried both:
var path = jQuery.sap.getModulePath("Z_LOP_WORKLIST/Z_LOP_WORKLIST", "/model/AppData.json");
path = jQuery.sap.getModulePath("Z_LOP_WORKLIST.Z_LOP_WORKLIST", "/model/AppData.json");
I think we searching on the wrong location.
Is there no simple github project which is loading a simple json file? (Generally: json models which are defined in manifest.json should be loaded automatically, or not?)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
then you should put z_lop_worklist.z_lop_worklist in the call, no need to change to /
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No. My ID is z_lop_worklist.z_lop_worklist. I know it's not the best ID or namespace. But it should work fine, or not?
Is there a example project at gitgub or something else (with a simple json file) which should also work fine an ABAP Stack?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
why your id is z_lop_worklist/z_lop_worklist? you have / in between?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jun, Hello Pinaki,
Thank you for your response. Yes I took value from "sap.app":{"id":....
In WebIde all works fine. But when I deploy the app to our abap backend the json file could not be loaded.
I can see that in runtime mode the component is separated into different Folders:
I don't understand what is wrong. I made a simple Project which loads a simple json file:
Maybe you can help me once again.Best regards Uwe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"sap.app": {
"id":*******
did you put this id vlaue in the getmodulepath call?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uwe,
if you look at the 404 error url it is pointing to ...ushell/resources/... to pickup the json file which I belief is wrong.
in Component.js
or https://blogs.sap.com/2017/04/30/how-to-include-third-party-libraries-modules-in-sapui5/
BR
Pinaki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var path=jQuery.sap.getModulePath("youappiddefinedinmanifest","/model/AppData.json")
YOURJSONMODEL.loadData(path);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.