Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

save PDF file in server

Hi expert,

i want to save 1 PDF in server, i did it as below.

use otf function module to convert smartform into binary format,

then use open dataset , transfer data in internal table into pdf file in server.

all of these are working fine, but at last, when i am trying to open this PDF file, it gives an error, saying file is damaged. please help. thanks.

Former Member replied

Hi

I use this code in a my program and it works fine:

  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
    IMPORTING
      bin_filesize          = bin_filesize
      bin_file              = pdf_bin
    TABLES
      otf                   = p_otf[]
      lines                 = t_lines
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      err_bad_otf           = 4
      OTHERS                = 5.
  IF sy-subrc <> 0.
    ............................
* PDF
    pdf_content = cl_document_bcs=>xstring_to_solix( pdf_bin ).
    IF bin_filesize > 0.
      OPEN DATASET work_path_pdf FOR OUTPUT IN BINARY MODE.
      IF sy-subrc <> 0.
        cf_retcode = sy-subrc.
        MESSAGE e208(00) WITH 'Errore in apertura file'(004) INTO l_message.
      ENDIF.
      CHECK cf_retcode = 0.
      LOOP AT pdf_content INTO l_pdf.
        TRANSFER l_pdf TO work_path_pdf.
      ENDLOOP.
      CLOSE DATASET work_path_pdf.
     ...............

It sould be similar to your code

Max

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question