‎2007 Jan 29 10:36 AM
i am having xml data in an internal table, my query is that i want to display the data in the internal table ie xml data into pdf format.
<b>or.</b>
i am having xml data in the local system and i want to pick that xml data and generate the pdf file for that xml data.
send me in the proper and in the clear way ie step by step how to do
‎2007 Jan 29 2:39 PM
‎2007 Jan 29 3:40 PM
Hai Santosh,
Go through the following Code
&----
*& Report ZPDF_CREATE
*&
&----
*&
*&
&----
REPORT ZPDF_CREATE.
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.
Here you just pass the Spool No(Already Existed on check with SP01 Tcode)
You will give the Spool No with Output List only
and Give File Down load Path and Execute.
Regards
Sreeni
‎2007 Jan 30 12:00 PM
hello srinu,
i tried u r code, it is working but i am not getting the entire record, some of rows in the record is being truncated, if i am giving .pdf as extension, if i am not giving the extension i am getting all the rows of the record
‎2007 Jan 30 1:09 PM
Hi Santosh,
If you have xml data in an internal table then try using anyone of the following function module:
CONVERT_OTF
or
CONVERT_OTF_2_PDF
Reward points if helpful answer.
Ashven
‎2007 Feb 06 10:02 AM
hi srinu,
i tried ur code it is working fine, but i am having more than 1000 pages in spool but while converting the data into pdf format it is giving error as
6248
6249 * add line to stream, with a leading blank
6250 FORM PDF_APPEND_STREAM USING VALUE(LINE) TYPE C.
>>>>> PDF_STREAM_TAB-L = LINE.
6252 SHIFT PDF_STREAM_TAB-L RIGHT. "add leading blank as token separator
6253 APPEND PDF_STREAM_TAB.
6254 ENDFORM.
6255
6256 * write contents stream
6257 FORM PDF_WRITE_CONT_STREAM.