2007 Aug 03 8:44 AM
hi all,
I have data in an internal table. i am not using any smartform function modules.
I just need to convert the itab data to pdf.
Can i convert it directly
PLEASE DONT RELATE IT TO SMART FORM FUNCTION MODULES.
I dont want to go through smartform way.
Cant i do it directly
2007 Aug 03 8:49 AM
2007 Aug 03 8:53 AM
Hi,
Use this Fm..
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOL_NR
IMPORTING
PDF_BYTECOUNT = PDF_FILESIZE
TABLES
PDF = PDF_OUTPUT.
*
SPOOL_NR_DEL = SPOOL_NR.
*
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
SPOOLID = SPOOL_NR_DEL.
*
BIN_FILESIZE = PDF_FILESIZE.
*
Regards,
Sankar
2007 Aug 03 8:53 AM
Hi,
print the itab, convert this Spool to pdf and download it.
Regards, Dieter
2007 Aug 03 8:56 AM
Hi
Try with this
Fms
CONVERT_OTF -->Convert OTF format to various formats (TLINE table)
CONVERT_OTF_2_PDF -->Convert OTF to PDF (TLINE table). OTF can be filled used archivelink. Calls CONVERT_OTF.
CONVERT_OTF_2_PDF_ARCHIVELINK -->Convert OTF to PDF (TLINE table). Calls CONVERT_OTF. Looks like the function names for these two functions are mixed up
CONVERT_OTFSPOOLJOB_2_PDF-->Input: spool # (SAPscript: tsp01-rqdoctype='OTF'); Output: PDF as internal table (TLINE)
<b> Example</b>
data: w_ident like tsp01-rqident,
w_doctype like tsp01-rqdoctype,
w_bytecount type i.
data: itab_pdf like tline occurs 0 with header line.
parameter spoolnum like tsp01-rqident obligatory.
selection-screen begin of block a2 with frame.
parameters: to_pc radiobutton group a2 default 'X',
pcfile like rlgrap-filename lower case,
to_unix radiobutton group a2,
unixfile(255) lower case.
selection-screen end of block a2.
********************************
at selection-screen on block a2.
********************************
if to_pc = 'X' and pcfile is initial.
message e398(00) with 'Enter PC File Name.'.
elseif to_unix = 'X' and unixfile is initial.
message e398(00) with 'Enter Unix File Name.'.
endif.
*******************************
at selection-screen on spoolnum.
*******************************
select single rqident rqdoctype
into (w_ident, w_doctype)
from tsp01
where rqident = spoolnum.
if sy-subrc ne 0.
message e398(00) with 'Spool' spoolnum 'not found'.
endif.
************************************************
at selection-screen on value-request for pcfile.
************************************************
call function 'WS_FILENAME_GET'
exporting
mask = ',*.*,*.*.'
importing
filename = pcfile
exceptions
others = 1.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*******************
start-of-selection.
*******************
if w_doctype = 'LIST'.
perform get_abap_spool_in_pdf.
elseif w_doctype = 'OTF'.
perform get_otf_spool_in_pdf.
endif.
if to_pc = 'X'.
perform write_pdf_spool_to_pc.
else.
perform write_pdf_spool_to_unix.
endif.
message i398(00) with 'Completed OK'.
************************************************************************
form get_abap_spool_in_pdf.
refresh itab_pdf.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = w_ident
importing
pdf_bytecount = w_bytecount
tables
pdf = itab_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.
if sy-subrc ne 0.
message e398(00) with 'Cannot convert to PDF. Error =' sy-subrc.
endif.
endform.
************************************************************************
form get_otf_spool_in_pdf.
refresh itab_pdf.
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = w_ident
importing
pdf_bytecount = w_bytecount
tables
pdf = itab_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
others = 12.
if sy-subrc <> 0.
message e398(00) with 'Cannot convert to PDF. Error =' sy-subrc.
endif.
endform.
************************************************************************
form write_pdf_spool_to_unix.
open dataset unixfile for output in binary mode.
if sy-subrc ne 0 .
message e398(00) with 'Cannot open unix file for output:' unixfile.
endif.
loop at itab_pdf.
transfer itab_pdf to unixfile.
if sy-subrc ne 0 .
message e398(00) with 'Cannot write to unix file:' unixfile.
endif.
endloop.
close dataset unixfile.
endform.
************************************************************************
form write_pdf_spool_to_pc.
call function 'WS_DOWNLOAD'
exporting
bin_filesize = w_bytecount
filename = pcfile
filetype = 'BIN'
tables
data_tab = itab_pdf
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10.
if sy-subrc <> 0.
message e398(00) with 'Cannot download to PC. Error =' sy-subrc.
endif.
endform.
CONVERT_ABAPSPOOLJOB_2_PDF -->Input: spool # (ABAP listing: tsp01-rqdoctype='LIST'); Output: PDF as internal table (TLINE)
RSPO_RETURN_SPOOLJOB -->Return spool data in text [or PDF format]:
Input: Spool #; Desired Type for output (RAW - text data ready to be printed, PDF - can be used only for OTF spools)
Output: text table (line length = 255), [table for PDF data]
RSPO_DISPLAY_SPOOLJOB--> Input: Spool #
Reward all helpfull answers
Regards
Pavan