cancel
Showing results for 
Search instead for 
Did you mean: 

Open PDF from WebDynpro ABAP

Former Member
0 Kudos

Hi,

I see a lot of questions in the forum around having problems opening a PDF from a webdynpro. However, I cannot find any with answers to solve my problem. I am getting an error,"There was an error opening this document... file may be corrupt" when trying to open a PDF from a dynpro.

I am putting the data I need in the PDF into a string. I am then taking that string and converting it to an xstring with the FM SCMS_STRING_TO_XSTRING. Then, I call attach_file_to_response, exporting filename = 'CommissionReport.pdf', content = my xstring, and mime_type = 'application/pfd'. Does anybody have an idea of what I may be doing wrong?

Thanks,

Carrie

Accepted Solutions (0)

Answers (2)

Answers (2)

KiranJ
Active Participant
0 Kudos

Hai ,

to show smart form in pdf in Web Dynpro abap use the following FM's

SSF_FUNCTION_MODULE_NAME'

'SSFCOMP_PDF_PREVIEW'

'CONVERT_OTF'

its helpful

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>I am putting the data I need in the PDF into a string.

Yes, but how are you actually building the PDF? Are you using the InteractiveForm UI element or calling a function module generated for a form interface? What is this string with data and how are you merging it with the PDF form definition?

Former Member
0 Kudos

I am not using the interactive form. I am probably missing a funtion module like you mentioned. This code works if I use the MIME types of XLS, DOC & TEXT/PLAIN, just now when trying to use the MIME type of APPLICATION/PDF. Here is my code...

CONCATENATE l_text

ls_header-report_description

ls_header-date_paid

ls_header-user_id_name

ls_header-job

ls_header-route

INTO l_text SEPARATED BY cl_abap_char_utilities=>newline.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = l_text

IMPORTING

buffer = l_xtext.

cl_wd_runtime_services=>attach_file_to_response(

i_filename = 'CommissionReport.pdf'

i_content = l_xtext

i_mime_type = 'application/pdf ).

Thanks,

Carrie

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>This code works if I use the MIME types of XLS, DOC & TEXT/PLAIN

It works for those applications because they use text based formats. With the MIME type you aren't transforming the data in any way, you are just telling the client machine which application should be use to open the data.

PDF on the other hand is not a simple text based format. It is binary - and not simple by any means. You can't just manipulate the data and turn it into a PDF. Generally you design a PDF form using Adobe Lifecycle Design (via Transaction SFP or inside SE80). You create a form interface and map the data from this interface into the layout of the form. You then either integrate this form into Web Dynpro ABAP via the InteractiveForm UI element and binding to the WD context. The other approach (which is generally used in print forms) is to generate a function module (just like SmartForms did) for the form interface. You can then call this function module passing your input data and receiving a byte stream (XSTRING variable) with the rendered PDF format. This does require the installation and configuration of the Adobe Document Services software component into a NetWeaver Java AS in your landscape. The ABAP system then calls the ADS via a Web Service for the actual rendering of the PDF.

Former Member
0 Kudos

Thanks for your help. If I were to create a function module, like one used with SmartForms, do I still need to map the data to something to get it to display, or how does that work? I guess I am just unsure how to go about creating a function for this.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Just like in SmartForms, the Function Module is generated for you when you activate the Form Interface. I suggest that you have a look at the following section of the online help:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/c8/4adf7ba13c4ac1b4600d4df15f8b84/frameset.htm

Former Member
0 Kudos

Check out this thread for [Smartform in Abap Webdynpro |]

Former Member
0 Kudos

Thank you very much for your help, Thomas. It seems like that would be a very good approach for me to use, however, we do not have Adobe LiveCycle Designer installed, so that will not work for us right now. I will keep this in mind for the future. I will resort to using a SmartForm for now. Thanks again for your help.