cancel
Showing results for 
Search instead for 
Did you mean: 

Display PDF file from Kpro in webbrowser

Daniel_Degenhardt
Product and Topic Expert
Product and Topic Expert
0 Kudos
968

Hi experts,

I need to display a PDF file in a web browser, therefore I use the function module "SDOK_PHIO_GET_URL_FOR_GET" to generate an HTTP link.

When I use this link in the web browser the file gets downloaded. It however doesn't have a file type so it doesn't automatically get opened in the web browser. It is no problem to open it with the adobe reader. I think the cause is that the link only contains the document id. Could it be that it has anything to do with the mime types? How could I fix this problem?

Here you can see the link.

http://i32lp1.in.tum.de:8032/sap/bc/contentserver/301?docGet&pVersion=0045&contRep=DMS_C1&docId=5C0B...

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor

When a file is stored in the KPro, it is stored along with a file name and a MIME type. When you execute the URL, SAP will extract the file based on the "docId" and "contRep" (there's possibly also the "compId" which refers exactly to one file), and send the HTTP response with header's ContentType set to the MIME type, and the file content is in the response body.

So, there should be no error unless the MIME type was incorrectly stored in the content repository.

When your URL is executed, the class CL_HTTP_EXT_CSIF is executed (as you can see in transaction SICF for the service contentserver), "docGet" corresponds to the method PROCESS_DOCGET, so you may set a user break-point inside the method to understand what's going on more precisely (make sure which user is to be debugged).

Daniel_Degenhardt
Product and Topic Expert
Product and Topic Expert

additonal:

Instead of using SDOK_PHIO_GET_URL_FOR_GET it's much better to use CVAPI_DOC_VIEW to generate an HTTP Link.

Sandra_Rossi
Active Contributor
0 Kudos

danielfulda why better? 🙂

Daniel_Degenhardt
Product and Topic Expert
Product and Topic Expert
0 Kudos

@sandra.rossi

Okay, let's say it's easier in my case 😄

Like you mentioned before the method PROCESS_DOCGET gets executed. Inside this method 'in my case' the method SCMS_BINARAY_TO_XSTRING gets executed. This method doesn't import any mime-type. I think this has some logical reason.

Somehow I tried the CVAPI_DOC_VIEW to provide an URL for the original file. The difference in this URL is, that you have an additional compId. (Oh okay just in the moment I see that here the method "get" is used)

http://i32lp1.in.t.....2/sap/bc/contentserver/301?get&pVersion=0045&contRep=DMS_C1&docId=5C0F772974A...∁Id=daniel.pdf

To be honest I haven't looked deeper into it. I'm only happy that it worked out for me 🙂

Sandra_Rossi
Active Contributor

danielfulda thank you for sharing these informations... it can help in the future, myself or anybody else...

Answers (0)