04-08-2009 12:32 PM
Hi Experts,
After ECC 6.0, HR-W2 and W2C Form Spools are getting generated in PDF format.
We have a requirement wherein we want to read the PDF Spool Programatically and write the PDF file to Application server (Using OPEN DATASET and CLOSE DATASET)
PARAMETERS : p_spono LIKE tsp01-rqident.
DATA: pdf_data type FPCONTENT.
types: lt_pdf_table(1000) type x.
data: l_pdf_data type standard table of lt_pdf_table,
l_pdf_line type lt_pdf_table,
l_offset type i,
l_len type i,
p_file(100) VALUE '\sapout\DVH\pdf2.pdf'.
*Read the spool content
CALL FUNCTION 'FPCOMP_CREATE_PDF_FROM_SPOOL'
EXPORTING
i_spoolid = p_spono
i_partnum = '1'
IMPORTING
e_pdf = pdf_data
* e_pdf_file = file
EXCEPTIONS
ads_error = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
* Modify the spool contents to prepare internal table
l_len = xstrlen( pdf_data ).
while l_len >= 1000.
l_pdf_line = pdf_data+l_offset(1000).
append l_pdf_line to l_pdf_data.
add 1000 to l_offset.
subtract 1000 from l_len.
endwhile.
if l_len > 0.
l_pdf_line = pdf_data+l_offset(l_len).
append l_pdf_line to l_pdf_data.
endif.
*--------------------------------------------------------------------
* GUI DOWNLOAD Works Fine
*--------------------------------------------------------------------
* Now pdf contents is ready , lets store in local PC
*CALL FUNCTION 'GUI_DOWNLOAD'
* EXPORTING
* filename = 'C:\Documents and Settings\Desktop\shital.pdf'
* filetype = 'BIN'
* TABLES
* data_tab = l_pdf_data.
OPEN DATASET p_file FOR OUTPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE ID '00' TYPE 'E' NUMBER '398' WITH 'sy-subrc:' sy-subrc
' Error opening file:'(Z03) p_file.
ENDIF.
LOOP AT l_pdf_data INTO l_pdf_line.
TRANSFER l_pdf_line TO p_file.
ENDLOOP.
CLOSE DATASET p_file.
IF sy-subrc <> 0.
MESSAGE ID '00' TYPE 'E' NUMBER '398' WITH 'sy-subrc:' sy-subrc
' Error closing file:'(Z04) p_file.
ENDIF.
Currently as you can see I have commented out GUI_DOWNLOAD Function Module, But it works perfect when I try to Download file to Local Desktop.
But when I try to pass the same Contents to Application server file and then try to open it by downloading file then it opens BLANK pdf file.
As per requirements I should be able to write the file correctly on Application server and If I dowload it from there it should open PDF file correctly.
Let me know if you require further details about the issue.
Regards
Shital
Edited by: shital phadake on Apr 8, 2009 9:39 PM
04-09-2009 9:03 AM
04-09-2009 4:07 PM
04-15-2009 1:23 PM
Thanks Selçuk for your reply and taking time for understanding the Issue,
I went thru Functionality of the program you suggested but dont think it matches my requirement.
Regards
Shital
05-10-2009 6:35 PM
11-02-2010 8:28 AM
Hi
I also have to do the same thing, can uplease help.
I have to send the spool output which is in pdf format to application server
Regards
Manu
11-08-2010 10:46 AM
Hi Shital,
I also have to write the pdf formatted spool to app server.
Would be thankful if you can help.
Regards
Manu
11-08-2010 11:06 AM
check application server path.
mention the appication server path
when you are using opendata set
09-20-2019 9:27 PM
Make the following change:
*LOOP AT l_pdf_data INTO l_pdf_line.
TRANSFER pdf_data TO p_file.
*ENDLOOP.
*if that doesn't work then you need to adjust how you are download from server to pc.
DO.
CLEAR: ls_bin, lv_len.
READ DATASET iv_file INTO ls_bin LENGTH lv_len.
IF sy-subrc <> 0.
IF lv_len > 0.
ADD lv_len TO lv_size.
APPEND ls_bin TO lt_bin.
ENDIF.
EXIT.
ELSE.
ADD lv_len TO lv_size.
APPEND ls_bin TO lt_bin.
ENDIF.
ENDDO.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = lv_size
filename = file
filetype = 'BIN'
CHANGING
data_tab = lt_bin