Let's follow up this discussion at the Neptune Community
(this forum will be kept in read-only mode)
I am trying to display an SAP standard report as aPDF document using PDF viewer in Neptune. I have converted the report output to spool and then to PDF Format and finally to XSTRING and used the FM 'SCMS_BASE64_ENCODE_STR' to encode it to base 64. However, after executing the PDFView.Show() method I am gettting an error message saying InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded. How to resolve this?
I am attaching the PDF file that i am trying to display in the PDF view.
The file attached is not Base64 encoded data. Can you please check it and try again with Base64 encoded PDF data ?
I had actually tried before by encoding the PDF data to BASE64 but it didn't work and I got the above error message in Chrome debugger. Please find attached the files 1. The PDF data in XSTRING format and 2. The XSTRING data converted to BASE64 format which resulted in the above mentioned error.
Appreciate your help.
Below is the code that I am using in my backend method
DATA: lt_pdf_convert TYPE tline,
lt_pdf_data TYPE TABLE OF tline,
ls_pdf_data TYPE tline,
lv_outputstring TYPE string,
lv_spono TYPE tsp01-rqident,
ls_params TYPE pri_params,
lv_valid_flag(1) TYPE c,
lv_rq2name TYPE tsp01-rq2name,
ls_tsp01 TYPE tsp01,
lv_len_pdf_bytes TYPE i.
lv_spono = '5905'.
*--- Spool in PDF Format konvertieren ---*
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
src_spoolid = lv_spono
no_dialog = 'X'
pdf_bytecount = lv_len_pdf_bytes
pdf = lt_pdf_data
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 = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
IF sy-subrc NE 0.
* RAISE error_convert_spool_2_pdf.
FIELD-SYMBOLS: <l_xline> TYPE x.
DATA : l_pdf_xstring TYPE xstring.
LOOP AT lt_pdf_data INTO ls_pdf_data.
ASSIGN ls_pdf_data TO <l_xline> CASTING.
CONCATENATE l_pdf_xstring <l_xline>
INTO l_pdf_xstring IN BYTE MODE.
IF sy-subrc EQ 0.
CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
input = l_pdf_xstring
output = gs_pdf-pdf_data.
When I test your data from the txtafternew.txt, this is base64 encoded data and it works like a charm:
How is your code to show the PDF data ?
Hi Ole Andre,
It doesn't work for me. I guess I am doing something wrong but unable to idetntify what.. Please see the below code to show the PDF data :
var data = modeloPage.getData();
and my oPage is bound to a structure(gs_pdf) with the following type
BEGIN OF ty_pdf .
TYPES: pdf_data TYPE string .
TYPES: END OF ty_pdf .
GS_PDF TYPE ty_pdf.
Do you see something that might be the problem?
Sorry but I have now identified the issue due to which the PDF was not getting displayed, I had forgot to check the Receive button in the binding of the button.
The issue is now resolved and the PDF is getting displayed.
Thanks for your help.