Skip to Content
avatar image
-2
Former Member

send pdf with web service, using base64 encode

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,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 17, 2017 at 08:42 PM

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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • Nov 23, 2017 at 07:14 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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'.