‎2009 May 06 1:32 AM
Hi Guys,
I am designing a report with several pages of output and running it in background.
Is there a possibility to convert each page into an separate pdf format document ?
If I use ALV report as output, if its more than page, do I face any issue with pdf conversion.
Thanks
‎2009 May 06 2:05 AM
Check the Following code, This might be helpful:
form rstxpdft4 using filename.
*
* Read spool job contents (OTF or ABAP list) and convert
* to PDF, download PDF
*
data: download value 'X'.
data: lv_filename like rlgrap-filename.
lv_filename = filename.
data otf like itcoo occurs 100 with header line.
data cancel.
data pdf like tline occurs 100 with header line.
data doctab like docs occurs 1 with header line.
data: numbytes type i,
arc_idx like toa_dara,
pdfspoolid like tsp01-rqident,
jobname like tbtcjob-jobname,
jobcount like tbtcjob-jobcount,
is_otf.
data: client like tst01-dclient,
name like tst01-dname,
objtype like rststype-type,
type like rststype-type.
select single * from tsp01 where rqident = gt_rq-rqident.
if sy-subrc <> 0.
write: / 'Spool request does not exist', gt_rq-rqident
color col_negative.
exit.
endif.
client = tsp01-rqclient.
name = tsp01-rqo1name.
call function 'RSTS_GET_ATTRIBUTES'
exporting
authority = 'SP01'
client = client
name = name
part = 1
importing
type = type
objtype = objtype
exceptions
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4.
if objtype(3) = 'OTF'.
is_otf = 'X'.
else.
is_otf = space.
endif.
if is_otf = 'X'.
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = gt_rq-rqident
no_dialog = ' '
importing
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
tables
pdf = pdf .
else.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = gt_rq-rqident
no_dialog = ' '
importing
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
tables
pdf = pdf
.
*************** download PDF file ***********
v_filename = lv_filename.
* call function 'WS_DOWNLOAD'
* exporting
* bin_filesize = numbytes
* filename = lv_filename
* filetype = 'BIN'
* tables
* data_tab = 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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* else.
* gv_count = gv_count + 1.
* endif.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = numbytes
FILENAME = v_filename
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = pdf .
* FIELDNAMES =Thanks.
‎2009 May 06 2:05 AM
Check the Following code, This might be helpful:
form rstxpdft4 using filename.
*
* Read spool job contents (OTF or ABAP list) and convert
* to PDF, download PDF
*
data: download value 'X'.
data: lv_filename like rlgrap-filename.
lv_filename = filename.
data otf like itcoo occurs 100 with header line.
data cancel.
data pdf like tline occurs 100 with header line.
data doctab like docs occurs 1 with header line.
data: numbytes type i,
arc_idx like toa_dara,
pdfspoolid like tsp01-rqident,
jobname like tbtcjob-jobname,
jobcount like tbtcjob-jobcount,
is_otf.
data: client like tst01-dclient,
name like tst01-dname,
objtype like rststype-type,
type like rststype-type.
select single * from tsp01 where rqident = gt_rq-rqident.
if sy-subrc <> 0.
write: / 'Spool request does not exist', gt_rq-rqident
color col_negative.
exit.
endif.
client = tsp01-rqclient.
name = tsp01-rqo1name.
call function 'RSTS_GET_ATTRIBUTES'
exporting
authority = 'SP01'
client = client
name = name
part = 1
importing
type = type
objtype = objtype
exceptions
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4.
if objtype(3) = 'OTF'.
is_otf = 'X'.
else.
is_otf = space.
endif.
if is_otf = 'X'.
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = gt_rq-rqident
no_dialog = ' '
importing
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
tables
pdf = pdf .
else.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = gt_rq-rqident
no_dialog = ' '
importing
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
tables
pdf = pdf
.
*************** download PDF file ***********
v_filename = lv_filename.
* call function 'WS_DOWNLOAD'
* exporting
* bin_filesize = numbytes
* filename = lv_filename
* filetype = 'BIN'
* tables
* data_tab = 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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* else.
* gv_count = gv_count + 1.
* endif.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = numbytes
FILENAME = v_filename
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = pdf .
* FIELDNAMES =Thanks.