Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZVS_MERGE_PDFS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZVS_MERGE_PDFS.
tables: tsp01.
select-options spool for tsp01-rqident.
parameters: p_file type localfile default 'C:\all_prints.pdf'.
data:
eof type soli,
tab1 type table of soli,
tab type table of soli with header line,
otf type table of itcoo with header line,
i_tsp01 like table of tsp01 with header line,
doc like table of docs,
pdf like table of tline,
file type string,
size type i,
lines type i,
rows type i.
file = p_file.
select * from tsp01 into i_tsp01
where rqident in spool.
append i_tsp01.
endselect.
rows = lines( i_tsp01 ).
if rows > '50'.
exit.
endif.
loop at i_tsp01.
clear: tab1[], eof.
call function 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = i_tsp01-rqident
TABLES
buffer = tab1
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
if sy-subrc = 0.
endif.
describe table tab1 lines lines.
read table tab1 index lines into eof.
delete tab1 index lines.
append lines of tab1 to tab.
endloop.
append eof to tab.
loop at tab.
clear otf.
otf = tab.
append otf.
endloop.
call function 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = size
TABLES
otf = otf
doctab_archive = doc
lines = pdf
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
others = 3.
if sy-subrc ne 0.
write sy-subrc.
endif.
call method cl_gui_frontend_services=>gui_download
EXPORTING
filename = file
filetype = 'BIN'
CHANGING
data_tab = pdf
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
others = 24.
if sy-subrc ne 0.
write sy-subrc.
endif.