‎2006 Dec 01 3:03 AM
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
‎2006 Dec 01 5:56 AM
hi Loo,
ty with my solution.
call this FM once 'CO_PRINT_REFRESH_DATA'. in starting point in your program, to refresh the data.
Please wirit whether u r problem is solved or not
Regards
Naresh Reddy.
‎2006 Dec 01 7:05 AM
Thanks for your reply Naresh. I've tried to call that FM 'CO_PRINT_REFRESH_DATA' but it didn't help. I still get that error message. Please advise.
‎2006 Dec 01 7:51 AM
Hi.. i've added this line
submit (sy-repid) to sap-spool without spool dynpro
spool PARAMETERS mstr_print_parms
and return.
added before
*-- Find out what the spool number is that was just created
perform get_spool_number using sy-repid
sy-uname
...
...
...
It will keep going back to my selection-screen unless i click the back button. when i click on the back button it will only convert the pdf file and it can be converted succesfully. Is there any way where i can modify the code so that it wont return to the selection-screen again and again when i click one execute ??
Please assist... i need this urgently.. thanks
‎2006 Dec 06 3:00 AM
Hie..just to update. The problem it keeps going back to the same screen when i use Submit (sy-repid) to sap-spool .... is because there's a mandatory field in the selection-screen. Once i removed the mandatory field.. it execute smoothly and as expected. Hope this information can help others.
Cheers,
Loo