Skip to Content
0
Jan 11, 2011 at 01:24 PM

Download PDF from application server after FTP

162 Views

Hi all,

Scenario:

We send a txt-file (with FTP) to a server, and we receive multiple files back. (.dat, .pdf, .xml, ...)

With the function ftp_server_to_r3, we move these files to our application server.

We are able to download the .txt, .xml, .dat files without any problems, but when we try to download the PDF files, we get an error that the file is corrupt.

FTP:

FTP_SERVER_TO_R3

OPEN DATASET gv_path FOR OUTPUT IN BINARY MODE.

LOOP AT gt_result INTO gs_result.

TRANSFER gs_result TO gv_path.

ENDLOOP.

CLOSE DATASET gv_path.

Download:

OPEN DATASET gv_path FOR INPUT IN BINARY MODE.

IF sy-subrc = 0.

CLEAR : lt_value.

REFRESH : lt_value.

DO.

READ DATASET gv_path INTO lt_value-tdline.

IF sy-subrc = 0.

APPEND lt_value.

ELSE.

EXIT.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET gv_path.

lv_filepath = gs_tab_file-filename.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

default_file_name = lv_filepath

CHANGING

filename = lv_filename

path = lv_path

fullpath = lv_full_path

user_action = lv_user_action

EXCEPTIONS

OTHERS = 99.

Any idea how we can solve this so we can open the PDF file?