cancel
Showing results for 
Search instead for 
Did you mean: 

How to serve runtime generated file on WAS?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

eddy_declercq
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Eddy,

Thank you very much!!!

Jeroen

eddy_declercq
Active Contributor
0 Kudos

You're welcome. Glad it helped.

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

By default nothing on the local file system is exposed via HTTP. You have to remember in productive ABAP systems, you often have multiple application servers (with separate file systems, and perhaps even a mixture of operating systems).

However you can setup an ICM File Handler. Lookup the documentation on the Profile Parameter icm/HTTP/file_access_X. You can map to local or remote directory.

Of course you can always read the data from the filesystem using OPEN DATASET, TRANSFER DATASET, Etc. and then expose the results via BSP as well.