Hi, I have a report to be converted to PDF format and then download the pdf as a local file. The code are as below.
My problem is each time i execute my program, it will show me a message saying "Spool request 0 does not exist". Then i wil have to delete that particular code (the code below), activate the program and then copy and paste back the code (the code below from elsewhere) and activate it again. The code i copied is exactly the same, nothing is changed. But i dont want to practice this method everytime i execute my program.
What are the cause to this problem and how should i solve it ? Please advise me..
Thanks.
Extracted Code ****
&----
*& Form print_pdf
&----
FORM print_pdf .
STRUCTURES
DATA: mstr_print_parms LIKE pri_params,
mc_valid(1) TYPE c,
mi_bytecount TYPE i,
mi_length TYPE i,
mi_rqident LIKE tsp01-rqident.
INTERNAL TABLES
DATA: mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
mc_filename LIKE rlgrap-filename.
CONCATENATE 'c:\EEOReport-' sy-datum '_' sy-uzeit '.pdf' INTO mc_filename.
Setup the Print Parmaters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = space
copies = '1'
list_name = space
list_text = space
immediately = space
release = space
new_list_id = 'X'
expiration = '1'
line_size = 132
line_count = 65
layout = 'X_65_132'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = mstr_print_parms
valid = mc_valid.
IF mc_valid <> space.
NEW-PAGE PRINT ON PARAMETERS mstr_print_parms NO DIALOG.
NEW-PAGE PRINT OFF.
ENDIF .
Make sure that a printer destination has been set up
If this is not done the PDF function module ABENDS
IF mstr_print_parms-pdest = space.
mstr_print_parms-pdest = 'LOCL'.
ENDIF.
Explicitly set line width, and output format so that
the PDF conversion comes out OK
mstr_print_parms-linsz = 132.
mstr_print_parms-paart = 'X_65_132'
.
Find out what the spool number is that was just created
PERFORM get_spool_number USING sy-repid
sy-uname
CHANGING mi_rqident.
Convert Spool to PDF
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = mi_rqident
no_dialog = space
dst_device = mstr_print_parms-pdest
IMPORTING
pdf_bytecount = mi_bytecount
TABLES
pdf = mtab_pdf
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = mi_bytecount
filename = mc_filename
filetype = 'BIN'
IMPORTING
act_filename = mc_filename
TABLES
data_tab = mtab_pdf.
ENDFORM. " print_pdf
&----
*& Form get_spool_number
&----
FORM get_spool_number USING P_SY_REPID
P_SY_UNAME
CHANGING P_MI_RQIDENT.
DATA: lc_rq2name LIKE tsp01-rq2name.
SELECT * FROM tsp01 WHERE rq2name = lc_rq2name
ORDER BY rqcretime DESCENDING.
P_MI_RQIDENT = tsp01-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR P_MI_RQIDENT.
ENDIF.
ENDFORM. " get_spool_number