on 05-03-2017 7:37 AM
Hi guys!
Is this scenario possible? First fill UI5 form, make a call to backend using the data from UI, generate a PDF file and then return it to the UI right away and display it inline?
The examples that I have seen are uploading or saving data to backend first using CREATE/CREATE_STREAM methods and then make another call to read it back again using READ/GET_STREAM methods. Some minimal key is passed along using slug and it's used to read the file from some table or so.
However, I would like to skip the saving part completely if possible. Just pass the data, generate a PDF and return it to UI in one go. Can this be done?
thanks!
Ossi
Yes, I have achieved it. This is how.
1. Use a batch request from UI to send a POST (PDF data) request as well as GET ($value - actual PDF)
2. In the CREATE_ENTITY method or CREATE_DEEP_ENTITY method (based on your PDF request body), store the request body (PDF data) as an instance attribute (custom) of your DPC_EXT class.
3. In the GET_STREAM method, you will have access to above instance attribute. With this data create a PDF (using Smartform) and return.
Note: You have to use a $ajax call for the batch call. This is because regular batch call will fail to parse the response (pdf data).
Let me know how it went. 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Krishna! This sounds very promising. I'd like to understand it a bit better.
- Do we still need two entities, one for data and one for the attachment? And we must link them via Association (1...N)?
- The instance attribute in the CREATE_ENTITY method. How does one store/read the request body there?
- Are there any examples for creating an ajax batch request?
It would be great if you could even write a short blog about this method! 🙂
-Ossi
- Number of Entities depends.
If your attachment entity can handle all the data, then you just require one. I required multiple entities to handle data. It was a deep create with header and items. (For PR). No association required between data entity and attachment entity. This is because you are issuing two separate calls within the batch call.
Sure, I will publish a blog soon. 🙂
Thanks Krishna!
Ok, I think we better have two entities because we have some 20 fields which are needed in order to generate the PDF.
However, if we would use only one entity for everything, would the Entity's Media-flag be set (because we have binary data within the entity too)?
It would be really awesome if you can publish an example blog! 🙂
br, Ossi
Hi Ossi,
Please check the below link.
http://www.inkyourcode.com/how-to-generate-pdf-file-in-sapui5/
Regards
Madhu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.