Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

send pdf with web service, using base64 encode

former_member382607
Discoverer
0 Kudos

Hi Gurus,

I have a PDF in from a smartform using CONVERT_OTF and i can see pdf with GUI_DOWNLOAD. but i need to send it with base64 format, i used SCMS_BINARY_TO_XSTRING and convert base64 but it doesnt work.

Does anyone have any advice for me?

Regards,

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

So, you have a bug in your code, but how could we tell you what/where it is.

0 Kudos

thank you for answer,

here is my code,

I submit a program in fm,

*** program codes

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
archive_index = archive_index
IMPORTING
bin_filesize = lv_bin_filesize
TABLES
otf = otf-otfdata
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1.

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_bin_filesize
IMPORTING
buffer = lv_xstring
TABLES
binary_tab = it_lines
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc EQ 0.
gt_py-xspdf = lv_xstring.
APPEND gt_py.
ENDIF.

IF gt_py[] IS NOT INITIAL.
EXPORT gt_py TO SHARED BUFFER indx(st) ID 'ZTEMP'.
ENDIF.

*** function module codes

IMPORT gt_py FROM SHARED BUFFER indx(st) ID 'ZTEMP'.

IF sy-subrc EQ 0.
READ TABLE gt_py INDEX 1.
IF sy-subrc EQ 0.
lv_pdf = gt_py-xspdf.
ENDIF.
ENDIF.

CALL FUNCTION 'SSFC_BASE64_ENCODE'
EXPORTING
bindata = lv_pdf
binleng = lv_length
IMPORTING
b64data = lv_base64
EXCEPTIONS
ssf_krn_error = 1
ssf_krn_noop = 2
ssf_krn_nomemory = 3
ssf_krn_opinv = 4
ssf_krn_input_data_error = 5
ssf_krn_invalid_par = 6
ssf_krn_invalid_parlen = 7
OTHERS = 8.

i cant see lv_base64 like a pdf.

Sandra_Rossi
Active Contributor
0 Kudos

Based on the code you have posted, I can tell:

  • you export the PDF as a table of fixed-length lines, but you don't export the length in bytes, how can you deduce it when you convert to base 64 (how do you calculate LV_LENGTH?)
  • why don't you retrieve directly the xstring parameter from CONVERT_OTF, containing the PDF, and exporting it as is.

But I still don't understand why you say "it doesn't work", and "cant see base 64 like a pdf". What do you mean exactly? What did you try? Please give concrete and clear examples, eventually screen shots, etc.

0 Kudos

i try to send payslip pdf with web services using base64 format. payslip is calculated a program so i used submit in a function module.

lv_length is not calculated.

the company which use my web service said me 'we decode your webservice value, but it doesnt work'.