Skip to Content
0

PDF download in SAPUI5 using oData

Apr 16 at 09:19 AM

277

avatar image

Hello,

I want to invoke an oData read service which returns PDF file as output. The oData url would look as follows:

/sap/opu/odata/SAP/ZYG_PDF_DWNLD_SRV/FILE_ENTITYSet('XYZ')/$value

I know how to invoke read operation from an entity set using standard SAPUI5 APIs. However, I am confused about the $value suffix in this oData invocation. How can I invoke the above url using SAPUI5 oData APIs.

Please provide the SAPUI5 code snippet which executes the above oData service

Note: If nothing is possible, my final work around is: construct the url in the above format using javascript and execute it using an ajax call. Before I do that, I would like to know the approach using standard API, hence posted this thread.

SAP Learner

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

4 Answers

Tri Minh Le Apr 18 at 04:49 AM
1

Hi SAP Learner,

You can try this approach

File Upload/Download through NetWeaver Gateway

Regards,

Tri

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hello Tri,

Thanks for that.

The topic in the link talks more about the oData development for File upload/download. I am looking for SAPUI5 code snippet which can invoke the oData file download service in a standard approach. Can you please provide that information

Regards,

SAP Learner

0
SAP Learner Apr 17 at 09:44 AM
0

Can someone please help me here?

Share
10 |10000 characters needed characters left characters exceeded
Desiree Matas
Apr 17 at 10:53 AM
0

Hi SAP learner,

This is more related to the gateway technology than to UI5. Adjust your tags so that the community can address the question better.

Best regards,

Désirée

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Desiree,

I have added Gateway service tag also to this thread.

As my query is to provide the SAPUI5 code snippet for executing the specified oData service, I have retained the primary tag as SAPUI5. I hope you agree with that

Regards,

SAP Learner

0
SAP Learner Jun 13 at 01:47 PM
0

Hello All,

I am trying to execute the following oData url from UI5 controler. It returns pdf file, when executed from Gateway client.

/sap/opu/odata/XXX/YYY_SRV/PDF_ENTITYSet(Empid='50160458',Begda=datetime'2018-05-31T00:00:00',Endda=datetime'2018-05-31T00:00:00')/$value

Code which I have tried to execute from controller is as follows:

var sServicePath = "/PDF_ENTITYSet(Empid='50160458',Begda=datetime'2018-05-31T00:00:00',Endda=datetime'2018-05-31T00:00:00')/$value";

oBackendModel.read(sServicePath, null, null, true, that.function(){ alert("Read success"),function(){ alert("Read failed");});

However, it fails always and shows "Read Failed" alert. I have gone through many examples where input is a normal string everywhere and tried to follow that approach here as well. I did not see single example where date is used as input to Entity set parameter. I am guessing that the issue is with datetime input in the url supplied during read.


Can anyone spot the issue here and provide suggestion on how to make this working?


Regards,

SAP Learner

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Couple of things you can update here after verifying your codebase -

1. See sample code here

2. Debug the behavior of GET_STREAM or READ_STREAM method.

0

Hello Ankit,

The link mentioned talks about upload. In fact, I am looking for an example where download happens through an oData service with date input within entityset parameter.

Would be of great help if you can give an example which meets the above specs.

Regards,

SAP Learner

0