08-17-2007 4:51 PM
Hi Experts,
Can ny body give the example code for converting spool to PDF conversion.
I have used the following FM for that.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = w_spoolno
no_dialog = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
pdf_bytecount = w_numbytes
pdf_spoolid = w_pdfspoolid
OTF_PAGECOUNT =
btc_jobname = w_jobname
btc_jobcount = w_jobcount
TABLES
pdf = t_pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 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.
ENDIF.
But after exicuting this FM i am getting data into t_pdf table in some different format which is not at all readble.Can ny body tell me how to resolve this?
Regards
08-17-2007 4:58 PM
check program RSTXPDFT4...
you can sumit this program with spool number and file path if you wish..
08-17-2007 4:54 PM
hi Ravi,
Check this out
FORM CONVERT_SPOOL_TO_PDF.
GD_SPOOL_NR = SPOOL_ID.
CALL FUNCTION 'RSPO_GET_TYPE_SPOOLJOB'
EXPORTING
RQIDENT = SPOOL_ID
IMPORTING
IS_OTF = I_OTF
EXCEPTIONS
CAN_NOT_ACCESS = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID 'Z1' TYPE 'E' NUMBER 000
WITH TEXT-002.
ELSEIF I_OTF EQ 'X'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOL_ID
IMPORTING
PDF_BYTECOUNT = PBYTE
TABLES
PDF = IT_PDF_OUTPUT
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 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.
ELSE. " Generar PDF de Abap
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOL_ID
IMPORTING
PDF_BYTECOUNT = PBYTE
TABLES
PDF = IT_PDF_OUTPUT
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.
IF SY-SUBRC EQ 0.
* Iniciamos la traducción por error en la funcion de conversion ABAP-PDF
LOOP AT IT_PDF_OUTPUT INTO I_PDF.
TRANSLATE I_PDF USING ',.'.
MODIFY IT_PDF_OUTPUT FROM I_PDF.
ENDLOOP.
ENDIF.
ENDIF. "De if sy-subrc
* TRANSLATE IT_PDF_OUTPUT USING ' ~'.
* CONCATENATE GD_BUFFER IT_PDF_OUTPUT INTO GD_BUFFER.
* ENDLOOP.
*
TRANSLATE GD_BUFFER USING '~ '.
DO.
IT_MESS_ATT = GD_BUFFER.
APPEND IT_MESS_ATT.
SHIFT GD_BUFFER LEFT BY 255 PLACES.
IF GD_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
* endif.
ENDFORM. "convert_spool_to_pdf
08-20-2007 11:01 AM
Hi All,
Thanks,
But my script is in russian language.
When i give spool number in SP01 t-code it is dispaying fine as i get out put of script.The same spool number if i pass to standard program RSTXPDFT4 ,then also i am not getting the desire output.It is showing in some format which is not alt all readable.
So how can this resolve?
Regards
08-17-2007 4:58 PM
check program RSTXPDFT4...
you can sumit this program with spool number and file path if you wish..
08-17-2007 7:03 PM
Pawan's suggestion is a good one.. check out that program, then you can use the FM that it uses - CONVERT_ABAPSPOOLJOB_2_PDF
08-20-2007 11:31 AM
Hi,
Check the following code:
report zabap_2_pdf.
*-- Enhancements: only allow to be run with variant. Then called
*-- program will be transparent to users
*-- TABLES
tables:
tsp01.
*-- 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.
*-- SELECTION SCREEN
parameters:
p_repid like sy-repid, " Report to execute
p_linsz like sy-linsz default 132, " Line size
p_paart like sy-paart default 'X_65_132'. " Paper Format
start-of-selection.
concatenate 'c:\'
p_repid
'.pdf'
into mc_filename.
*-- Setup the Print Parmaters
call function 'GET_PRINT_PARAMETERS'
exporting
authority= space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
in_archive_parameters = space
in_parameters = space
layout = space
mode = space
new_list_id = 'X'
no_dialog= 'X'
user = sy-uname
importing
out_parameters = mstr_print_parms
valid = mc_valid
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
*-- 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 = p_linsz.
mstr_print_parms-paart = p_paart.
submit (p_repid) to sap-spool without spool dynpro
spool parameters mstr_print_parms
via selection-screen
and return.
*-- 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.
----
FORM get_spool_number *
----
Get the most recent spool created by user/report *
----
--> F_REPID *
--> F_UNAME *
--> F_RQIDENT *
----
form get_spool_number using f_repid
f_uname
changing f_rqident.
data:
lc_rq2name like tsp01-rq2name.
concatenate f_repid+0(8)
f_uname+0(3)
into lc_rq2name separated by '_'.
select * from tsp01 where rq2name = lc_rq2name
order by rqcretime descending.
f_rqident = tsp01-rqident.
exit.
endselect.
if sy-subrc ne 0.
clear f_rqident.
endif.
endform.
Hope this helps.
Reward if helpful.
Regards,
Sipra
08-20-2007 11:32 AM
Hi Ravi,
The problem is with Fonts, Please start analysing in that area, check for the supported fonts for the Russian letters. While converting to PDF SAP uses standard fonts. you need to configure specific fonts to a printer in the transaction SPAD. If it is done already. In your program pass the printer name which you are using to take the print out of the sap script.
Regards
Vijayanand
08-20-2007 11:37 AM