on 04-04-2017 11:14 AM
Hi All,
I am trying to implement the functionality of downloading file (Word Document ) from Hana DB Table.
I stored a file in HANA DB and trying to download the file through UI.
But when i try to run the xsjs service am able to download the file successfully.
But when am trying to call the same xsjs on click it is throwing the below error.
The following problem occurred: parsererror - Word.doc,200,OK
Below is my code return to call xsjs service
downloadDocument : function()
{
var downloadModel = new sap.ui.model.json.JSONModel();
var caseParameters = {}; var caseId = sap.ui.getCore().byId("casesViewId").getValue(); caseParameters.CASEID = caseId;
downloadModel.loadData('http://xx.xxx.xxx.xx:xxxx/Valuefact/services/dowload.xsjs',caseParameters);
}
Could anybody please help me to resolve the issue.
Regards,
Shekar
Hi Florian Pfeffer,
Every assumption made by you is perfectly right.
As per you suggestion i cahnged the code as below.
downloadDocument : function()
{
var downloadModel = new sap.ui.model.json.JSONModel();
var caseParameters = {};
var caseId = sap.ui.getCore().byId("casesViewId").getValue(); caseParameters.CASEID = caseId;
//downloadModel.loadData('http://xx.xxx.xxx.xx:xxxx/Valuefact/services/dowload.xsjs',caseParameters,'POST'); window.open('http://xx.xxx.xxx.xx:xxx/Valuefact/services/dowload.xsjs',caseParameters);
}
This time after triggering the aboce method in a new window it is giving a message as "Document not found"
Could you please help me how can i resolve it.
Regards,
Shekar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you checked the information you get in the developer console of your browser (http status, any errors, ...)?
Have you checked that your service path is correct (is the typo in "dowload.xsjs" - instead of "download.xsjs" - correct)?
The 2nd argument for window.open is not an object which can be used for parameters like your caseid, you have to add the parameter to the URL.
Let me assume what you are trying to do: You read your word document via from a DB table and wanna download it via a browser window (according to your content-disposition response header setting set to an attachment value). When you are executing the service directly in the browser it works (cause the response is directly processed by the browser), if you try to do it in your UI5 app with the shown coding it does not work. Right?
If it is so, the coding does not work, cause you are trying to load the word document via a JSON Model. The loadData method tries to parse the response, cause a a JSON Model expects to get a JSON encoded response. That is not the case in your situation, cause your xsjs service does not deliver a JSON encoded response.
If you wanna download just the file, for instance just use the window.open function to call your xsjs service. This function calls your service and the browsers downloads your attachment.
Please also adjust the response content-type header in your xsjs service from "text/plain" to the valid value for your word format.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.