Skip to Content
avatar image
Former Member

PDF transfered via FTP is corrupted

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

pdf-by-cmd.jpg (105.0 kB)
pdf-by-sap.jpg (16.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jan 26 at 08:09 AM

    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 ?

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 27 at 02:46 PM

    Dear Em

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

    thanks

    JozsefH

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 29 at 01:40 PM

    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!

    Add comment
    10|10000 characters needed characters exceeded