<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error Occured While Reading File From FTP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722545#M2019860</link>
    <description>&lt;P&gt;Error happens randomly or always for the same file/s? Are you sure that the files with error are 100% character based?&lt;/P&gt;</description>
    <pubDate>Fri, 26 May 2023 06:07:48 GMT</pubDate>
    <dc:creator>Tomas_Buryanek</dc:creator>
    <dc:date>2023-05-26T06:07:48Z</dc:date>
    <item>
      <title>Error Occured While Reading File From FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722544#M2019859</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;
  &lt;P&gt;I want to get file data from ftp server to my internal table, in ftp sever directory having multiples files which is in .txt format , for read file from ftp i have used &lt;STRONG&gt;'FTP_SERVER_TO_R3' &lt;/STRONG&gt;. for most of the file this function module working fine and i am able to get data of my file into internal table ,but for some file while reading it's giving me sy-subrc 3 .&lt;/P&gt;
  &lt;P&gt;all files have same format, i don't know why its giving me &lt;STRONG&gt;sy-subrc 3 (Data Error)&lt;/STRONG&gt; .&lt;/P&gt;
  &lt;P&gt;for reference please see below code and attached screeenshots.&lt;/P&gt;
  &lt;P&gt;Thanks in Advance.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES : BEGIN OF ty_result ,&lt;BR /&gt;          line(100) TYPE c,&lt;BR /&gt;        END OF ty_result.&lt;BR /&gt;DATA : result1 TYPE TABLE OF  ty_result.&lt;BR /&gt;DATA:it_data TYPE TABLE OF ty_result,&lt;BR /&gt;     wa_data TYPE ty_result.&lt;BR /&gt;DATA :host(64),p_spath(50),&lt;BR /&gt;      dest        TYPE rfcdes-rfcdest.&lt;BR /&gt;DATA: hdl           TYPE i,&lt;BR /&gt;      key           TYPE i VALUE 26101957,&lt;BR /&gt;      cmd1(255)     TYPE c,&lt;BR /&gt;      cmd(255)      TYPE c,&lt;BR /&gt;      slen          TYPE i,&lt;BR /&gt;      in_dest(100)  TYPE c.&lt;BR /&gt;DATA: BEGIN OF i_oldfile OCCURS 1,&lt;BR /&gt;        line(1200) TYPE c,&lt;BR /&gt;      END OF i_oldfile.&lt;BR /&gt;  in_dest = '/home/Documents/ ' .&lt;BR /&gt;CALL FUNCTION 'HTTP_SCRAMBLE'&lt;BR /&gt;    EXPORTING&lt;BR /&gt;      source      = pwd&lt;BR /&gt;      sourcelen   = slen&lt;BR /&gt;      key         = key&lt;BR /&gt;    IMPORTING&lt;BR /&gt;      destination = pwd.&lt;BR /&gt;  IF sy-subrc EQ 0.&lt;BR /&gt;    CALL FUNCTION 'FTP_CONNECT'&lt;BR /&gt;      EXPORTING&lt;BR /&gt;        user            = user&lt;BR /&gt;        password        = pwd&lt;BR /&gt;        host            = host&lt;BR /&gt;        rfc_destination = dest&lt;BR /&gt;      IMPORTING&lt;BR /&gt;        handle          = hdl&lt;BR /&gt;      EXCEPTIONS&lt;BR /&gt;        not_connected   = 1&lt;BR /&gt;        OTHERS          = 2.&lt;BR /&gt;    IF sy-subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;BR /&gt;              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;BR /&gt;      WRITE:/ 'Not Connected'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;    ELSE.&lt;BR /&gt;      CALL FUNCTION 'FTP_COMMAND'&lt;BR /&gt;        EXPORTING&lt;BR /&gt;          handle        = hdl&lt;BR /&gt;          command       = 'set passive on'&lt;BR /&gt;        TABLES&lt;BR /&gt;          data          = result&lt;BR /&gt;        EXCEPTIONS&lt;BR /&gt;          command_error = 1&lt;BR /&gt;          tcpip_error   = 2.&lt;BR /&gt;      CONCATENATE 'cd' in_dest INTO cmd SEPARATED BY space.&lt;BR /&gt;      CALL FUNCTION 'FTP_COMMAND'&lt;BR /&gt;        EXPORTING&lt;BR /&gt;          handle        = hdl&lt;BR /&gt;          command       = cmd&lt;BR /&gt;        TABLES&lt;BR /&gt;          data          = result&lt;BR /&gt;        EXCEPTIONS&lt;BR /&gt;          command_error = 1&lt;BR /&gt;          tcpip_error   = 2.&lt;BR /&gt;**Get list file in FTP Folder&lt;BR /&gt;      CALL FUNCTION 'FTP_COMMAND'&lt;BR /&gt;        EXPORTING&lt;BR /&gt;          handle        = hdl&lt;BR /&gt;          command       = 'nlist'&lt;BR /&gt;        TABLES&lt;BR /&gt;          data          = it_data&lt;BR /&gt;        EXCEPTIONS&lt;BR /&gt;          tcpip_error   = 1&lt;BR /&gt;          command_error = 2&lt;BR /&gt;          data_error    = 3.&lt;BR /&gt;      LOOP AT it_data INTO wa_data WHERE line Cs 't4.txt'.    "getting data based on file name.&lt;BR /&gt;        CALL FUNCTION 'FTP_SERVER_TO_R3'&lt;BR /&gt;          EXPORTING&lt;BR /&gt;            handle         = hdl&lt;BR /&gt;            fname          = wa_data-line&lt;BR /&gt;            character_mode = 'X'&lt;BR /&gt;*      IMPORTING&lt;BR /&gt;*           blob_length    = ld_bloblen&lt;BR /&gt;          TABLES&lt;BR /&gt;*           blob           =&lt;BR /&gt;            text           = i_oldfile&lt;BR /&gt;          EXCEPTIONS&lt;BR /&gt;            tcpip_error    = 1&lt;BR /&gt;            command_error  = 2&lt;BR /&gt;            data_error     = 3&lt;BR /&gt;            OTHERS         = 4.&lt;A href="https://answers.sap.com/storage/temp/2169262-ftp-error.jpg" data-attachment="2169262"&gt;ftp-error.jpg&lt;/A&gt;&lt;A href="https://answers.sap.com/storage/temp/2169263-files.jpg" data-attachment="2169263"&gt;files.jpg&lt;/A&gt;&lt;BR /&gt;endloop.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 May 2023 05:57:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722544#M2019859</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2023-05-26T05:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error Occured While Reading File From FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722545#M2019860</link>
      <description>&lt;P&gt;Error happens randomly or always for the same file/s? Are you sure that the files with error are 100% character based?&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 06:07:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722545#M2019860</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2023-05-26T06:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error Occured While Reading File From FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722546#M2019861</link>
      <description>&lt;P&gt;Hello Tomas,&lt;/P&gt;&lt;P&gt;thanks for response ,&lt;/P&gt;&lt;P&gt;i am Getting error for random files not for any specific file, but all files having same format and same type of data.&lt;/P&gt;&lt;P&gt;in which most of file is reading successfully.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 06:34:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722546#M2019861</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2023-05-26T06:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error Occured While Reading File From FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722547#M2019862</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;joshiprasad&lt;/SPAN&gt; Oh, ok. I would suggest to check sy-msgid, sy-msgno etc. variables after the FM returns sy-subrc &amp;lt;&amp;gt; 0. And then if you can somehow repeat the error, then try debug little bit inside the FTP_SERVER_TO_R3. There you might find more details, some returning message most likely.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 06:57:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-occured-while-reading-file-from-ftp/m-p/12722547#M2019862</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2023-05-26T06:57:12Z</dc:date>
    </item>
  </channel>
</rss>

