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: 

PDF transfered via FTP is corrupted

Former Member
0 Kudos

Hi experts, I have an issue with a develop that uses FTP protocol.

Well, I have to transfer xml and pdf files from FTP Server to SAP App Server, to do it I use SAPFTPA, that allows me use App Server as local directory. The xml files goes well but the pdf files doesn't. The pdf file have content (when I open it via AL11) but when I try to see it with a pdf viewer it's shown in blank.

I have executed the transfer commands in terminal and the pdf files are ok.

This is the abap code I use to tranfer:

*setting local directory (ECC directory vía SAPFTPA)

   p_cmd = 'lcd /usr/sap/InterfaceSAP/XML_Rec_FacElec/PAC'.

    CALL FUNCTION 'FTP_COMMAND'
      EXPORTING
        handle        = l_handle
        command       = p_cmd
      TABLES
        data          = lit_mtab_data
      EXCEPTIONS
        tcpip_error   = 1
        command_error = 2
        data_error    = 3
        OTHERS        = 4.

*Setting transfer mode to binary
     p_cmd = 'binary'.

    CALL FUNCTION 'FTP_COMMAND'
      EXPORTING
        handle        = l_handle
        command       = p_cmd
      TABLES
        data          = lit_mtab_data
      EXCEPTIONS
        tcpip_error   = 1
        command_error = 2
        data_error    = 3
        OTHERS        = 4.

*create the command for ftp console << get file_name.pdf >>
    concatenate p_name '.' gc_ext3 into p_cmd.
    concatenate 'get' p_cmd into p_cmd separated by space.

    CALL FUNCTION 'FTP_COMMAND'
      EXPORTING
        handle        = l_handle
        command       = p_cmd
      TABLES
        data          = lit_mtab_data
      EXCEPTIONS
        tcpip_error   = 1
        command_error = 2
        data_error    = 3
        OTHERS        = 4.

*after transfer file delete it
    concatenate p_name '.' gc_ext3 into p_cmd.
    concatenate 'delete' p_cmd into p_cmd separated by space.

    CALL FUNCTION 'FTP_COMMAND'
      EXPORTING
        handle        = l_handle
        command       = p_cmd
      TABLES
        data          = lit_mtab_data
      EXCEPTIONS
        tcpip_error   = 1
        command_error = 2
        data_error    = 3
        OTHERS        = 4.

pdf-by-cmd.jpg

pdf-by-sap.jpg

pdf-content-al11.jpg

4 REPLIES 4

Sandra_Rossi
Active Contributor

Your code seems okay, because you transfer in binary mode.

So, the question is : after the FTP, how do you exactly proceed to display the file ?

jozsef_hegyi
Active Participant
0 Kudos

Dear Em

could you please send me the sapftp version, sapftp.exe -V

thanks

JozsefH

Former Member
0 Kudos

Hi everyone, thanks for quick answers I have solved the issue. It wasn't the FTP transfer, it was the path I take them from, so it shows in blank because, I din't remembered, I show a blank pdf when the viewer, of course this is in another develop, didn't found the pdf file in this path. Thanks!

0 Kudos

Thanks for the update. Please close the question, see this blog.