cancel
Showing results for 
Search instead for 
Did you mean: 

save PDF file in server

yang_aiolos
Active Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

yang_aiolos
Active Participant
0 Kudos

Hi Max, thanks. you help me a lot.

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Max!.

Emilio.

Former Member
0 Kudos

Hi Gurus!

Could you tell me how is your l_pdf defined?.

I mean data l_pdf like....

Thanks in advance.

Emilio.

Former Member
0 Kudos

Hi

You should check how the parameters of cl_document_bcs=>xstring_to_solix are defined, anyway it's like SOLIX

Max