2024 Apr 28 11:27 AM - edited 2024 Apr 28 11:29 AM
Hi ABAPers, I want to Download the PDF file using Program which is already generated in the SPOOL, I Tried using the below code
FM CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spool_id
no_dialog = 'X'
dst_device = 'PDF1'
pdf_destination = 'X'
IMPORTING
pdf_bytecount = lv_bin_size
pdf_spoolid = ev_spoolid
bin_file = lv_xstring
TABLES
pdf = lta_lt_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 <> 0.
* Implement suitable error handling here
ENDIF.
LTA_LT_PDF internal table is getting not any data from the FM, I can only see the binsize and xstring getting filled up, How to proceed further, Tried to convert xstring to PDF using
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring
TABLES
binary_tab = data_tab.
and
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_bin_size
filename = lv_path
filetype = 'BIN'
TABLES
data_tab = data_tab
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
OTHERS = 22.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
But PDF which is getting downloading looks corrupted, What could be the reason?
2024 Apr 28 12:50 PM - edited 2024 Apr 28 2:38 PM
Please format your code nicely. See Solved: How to post code in SAP Community >=2024 - SAP Community.
e.g. see how it looks after:
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring
TABLES
binary_tab = data_tab.
2024 Apr 28 1:02 PM - edited 2024 Apr 29 7:44 AM
First of all, there are several types of spool requests, ABAP List, OTF (SAPScript Form, Smart Form), Adobe PDF, etc.
CONVERT_ABAPSPOOLJOB_2_PDF is only for spool requests of type ABAP List.
If you use PDF_DESTINATION = 'X', only the parameter BIN_FILE is filled (not PDF_BYTECOUNT and not PDF).
One possible solution (among others):