Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to serve runtime generated file on WAS?

Hi,

In short: where (local path on application server) should I store a file (generated at runtime) in order to be able to offer it for downloading (via WAS)?

Context: I have a BSP application and I want to generate a PDF file (in the BSP app) and store that PDF locally on the server. In which local folder do I need to store that pdf so that it will be available remotely via WAS? Is there some folder in the local system that serves as WAS root folder?

Thanks!

Jeroen

Former Member
replied

Hi,

I wouldn't open the file system of the WAS for the public and let the WAS read the file itself and serve it to the client.

Eg

Open the file

OPEN DATASET file_path_pdf FOR input IN Binary mode message openmessage."text MODE encoding utf-8 .

if sy-subrc <> 0.

%>

<%=openmessage%>

<% mnavigation->response_complete( ).%>

<%

else.

read dataset file_path_pdf inTO pdfcontent.

CLOSE DATASET file_path_pdf.

endif.

Give it to the browser

runtime->server->response->set_data( pdfcontent ).

contentsize = xstrlen( pdfcontent ).

runtime->server->response->set_header_field( name = 'Content-Length'

value = contentsize ).

runtime->server->response->delete_header_field( name = 'Cache-Control' ).

runtime->server->response->delete_header_field( name = 'Expires' ).

runtime->server->response->delete_header_field( name = 'Pragma' ).

runtime->server->response->set_header_field( name = 'Content-Type'

value = 'application/pdf' ).

Eventual delet of the file

delete dataset file_path_pdf.

Set the reponse to complete to clear the buffers

mnavigation->response_complete( ).

Als take care when converting to PDF that you use unique file names in case you want to keep the files.

Eddy

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question