Home
> Web Dynpro Abap > Download a Smartform to Pdf from Web Dynpro Abap
Download a Smartform to Pdf from Web Dynpro Abap
This is an example to download a Smartform to PDF from a Web Dynpro Abap.
The method ONACTIONSHOW_PDF is binded to “onAction” event Button
method ONACTIONSHOW_PDF. DATA: smartform_fm TYPE rs38l_fnam, bin_pdf TYPE TABLE OF docs, bin_tline TYPE TABLE OF tline, bin_filesize TYPE i, bin_pdfx TYPE xstring, v_device_type TYPE rspoptype, v_output_options TYPE ssfcompop, v_control_parameters TYPE ssfctrlop. **CONVERT SMARTFORM TO BINARY XSTRING PDF CALL FUNCTION 'SSF_GET_DEVICE_TYPE' EXPORTING i_language = 'I' i_application = 'SAPDEFAULT' IMPORTING e_devtype = v_device_type EXCEPTIONS no_language = 1 language_not_installed = 2 no_devtype_found = 3 system_error = 4 OTHERS = 5. v_output_options-tdprinter = v_device_type. v_control_parameters-no_dialog = 'X'. v_control_parameters-getotf = 'X'. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = 'ZSMARTFORM' IMPORTING fm_name = smartform_fm EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. CALL FUNCTION smartform_fm EXPORTING control_parameters = v_control_parameters output_options = v_output_options id_document = doc_id IMPORTING job_output_info = v_output_stampa EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. ***CONVERT OTF TO PDF CLEAR: bin_pdf,bin_tline,bin_filesize,bin_pdfx. CALL FUNCTION 'CONVERT_OTF' EXPORTING format = 'PDF' IMPORTING bin_filesize = bin_filesize bin_file = bin_pdfx TABLES otf = v_output_stampa-otfdata lines = bin_tline. **ATTACH PDF TO RESPONSE CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE( i_filename = 'PDFSMARTFORM.PDF' i_content = bin_pdfx i_mime_type = 'application/pdf' ). endmethod.
Categories: Web Dynpro Abap
binary files, Pdf, Web Dynpro Abap
Where this PDF get stored …
PDF binary is created on runtime and sent back attached to the HTTP response (not stored in SAP file system)
Thanks it worked perfectly……
Only the problem is the page gets refreshed on first time download.
Is this issue faced by all??
I don’t remember to have faced this issue..