<?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: Get file from Server to internal table using FTP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680636#M1575991</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got the issue I was not changing the DIR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for this post !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 22 Nov 2014 08:11:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2014-11-22T08:11:40Z</dc:date>
    <item>
      <title>Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680627#M1575982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I dont know how to get or read a file from a server to an internal table in SAP.&lt;/P&gt;&lt;P&gt;I'm able to list what the server has, but how do i get into the file, read the context, get the info...&lt;/P&gt;&lt;P&gt;what i have until now is sth like this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: mc_password(20) TYPE c,
      mi_key TYPE i VALUE 26101957,
      mi_pwd_len TYPE i,
      mi_handle TYPE i,
      cmd(120).

DATA: BEGIN OF mtab_data OCCURS 0,
line(132) TYPE c,
END OF mtab_data.

DATA: wa_data LIKE mtab_data.

CONSTANTS: c_key TYPE i VALUE 26101957.

DATA: g_dpwd(30). "For storing password
CALL FUNCTION 'HTTP_SCRAMBLE'
  EXPORTING
    SOURCE      = mc_password "Actual password
    sourcelen   = '9'
    key         = c_key
  IMPORTING
    destination = mc_password. "Encyrpted Password

CALL FUNCTION 'FTP_CONNECT'
  EXPORTING
    user            = 'srv'
    password        = mc_password
    host            = '200.18.38.954'
    rfc_destination = 'SAPFTP'
  IMPORTING
    handle          = mi_handle
  EXCEPTIONS
    not_connected   = 1
    OTHERS          = 2.

CHECK sy-subrc = 0.

CALL FUNCTION 'FTP_COMMAND'
  EXPORTING
    handle        = mi_handle
    command       = 'dir'
  TABLES
    data          = mtab_data
  EXCEPTIONS
    tcpip_error   = 1
    command_error = 2
    data_error    = 3
    OTHERS        = 4.
* mtab_data contains the list of the all the files that are in the server
*I just want to get an specific file by date, such as 03-01
LOOP AT mtab_data INTO wa_data WHERE LINE CS '03-01'.
* the programs get inside the loop, because it knows that there is a file on 03-01
ENDLOOP.

CALL FUNCTION 'FTP_DISCONNECT'
  EXPORTING
    handle = mi_handle
  EXCEPTIONS
    OTHERS = 1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is on mtab_data is sth like this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
1	dir
2	200 PORT command successful.
3	150 Opening BINARY mode data connection for /bin/ls.
4	02-25-11  09:21AM               873288 MM_Costos_20110223.ci
5	03-01-11  08:02AM                   54 MM_Costos_20110301.txt
6	02-23-11  10:12AM               925900 MM_Demanda_20110223.ci
7	03-01-11  08:02AM                 3337 MM_Demanda_20110301.txt
8	02-25-11  09:21AM              1079589 MM_Materiales_20110223.ci
9	03-01-11  08:02AM                  101 MM_Materiales_20110301.txt
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to get the info of file "5	03-01-11  08:02AM                   54 MM_Costos_20110301.txt"&lt;/P&gt;&lt;P&gt;how can i access to that file?&lt;/P&gt;&lt;P&gt;I want to transfer the info of that file into an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i got it until there, some helps please.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 12:13:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680627#M1575982</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-01T12:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680628#M1575983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;look at your OPEN DATASET. . ., READ....., CLOSE keywords using ABAP Help (F1).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 12:35:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680628#M1575983</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-01T12:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680629#M1575984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for reply.&lt;/P&gt;&lt;P&gt;I did this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  open dataset 'MM_OC_PEND_20110219.txt' for input IN TEXT MODE ENCODING DEFAULT.
WHILE sy-subrc = 0.
  READ DATASET 'MM_OC_PEND_20110219.txt' INTO result.
  WRITE / result.
ENDWHILE.

CLOSE DATASET 'MM_OC_PEND_20110219.txt'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but sy-subrc = 8 after the open. It means that it didnt open it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am i doing wrong?&lt;/P&gt;&lt;P&gt;I thought that i can use some FM to transfer the file that i need to an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 13:06:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680629#M1575984</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-01T13:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680630#M1575985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;please go through this link&lt;/P&gt;&lt;P&gt;&lt;A href="http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP" target="test_blank"&gt;http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP&lt;/A&gt;&lt;EM&gt;solution&lt;/EM&gt;to&lt;EM&gt;implement&lt;/EM&gt;FTP+transactions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;S.Janagar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 13:18:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680630#M1575985</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-01T13:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680631#M1575986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I checked before, but it wasn't helpful.&lt;/P&gt;&lt;P&gt;I can't open or read the file data.&lt;/P&gt;&lt;P&gt;&lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;, I know that I'm missing sth, but until now I'm not able to figurate out what it is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 13:21:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680631#M1575986</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-01T13:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680632#M1575987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't see file 'MM_OC_PEND_20110219.txt'  ikn the mtab_data list. Check the offset where the filename starts, take it from there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally, you need to do ftp get command for fetching the file from ftp server and tansfer it to a directory where you have read authority granted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do some more search for ftp. ftp means file transfer protocol: You already accessed the ftp server and asked about the current directory content. Now you may change your local directory, use binary mode to get the file transfered, then finally you can use open dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 13:31:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680632#M1575987</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-03-01T13:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680633#M1575988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, yeap, u r right, but i changed the server, before i was poiting to PRD and now i'm using developer server, so that file is on that table.&lt;/P&gt;&lt;P&gt;I tried to so sth like u said to me&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT mtab_data INTO wa_data WHERE LINE CS '02-19'.

  CALL FUNCTION 'FTP_COMMAND'
    EXPORTING
      handle        = mi_handle
      command       = 'get MM_OC_PEND_20110219.txt'
    TABLES
      data          = mtab_data
    EXCEPTIONS
      tcpip_error   = 1
      command_error = 2
      data_error    = 3
      OTHERS        = 4.

ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i got sth like this on the mtab_data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
433	226 Transfer complete.
434	get MM_OC_PEND_20110219.txt
435	200 PORT command successful.
436	150 Opening BINARY mode data connection for MM_OC_PEND_20110219.txt(78 bytes).
437	226 Transfer complete.
438	78 bytes received in 0.00 seconds (0.08 Kbytes/s)
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it said transfer complete, but the file was transfer to where???&lt;/P&gt;&lt;P&gt;and then, how can i continue to get the info of that file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 13:36:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680633#M1575988</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-01T13:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680634#M1575989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess that i solved it,&lt;/P&gt;&lt;P&gt;I used the FM &lt;STRONG&gt;FTP_SERVER_TO_R3&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

CALL FUNCTION 'FTP_SERVER_TO_R3'
  EXPORTING
    handle               = mi_handle
    fname                = 'MM_OC_PEND_20110219.txt'
   CHARACTER_MODE       = '#'
* IMPORTING
*   BLOB_LENGTH          =
 TABLES
   BLOB                 = it_blob[]
   TEXT                 = it_text[]
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the table it_text contains the data of the file 'MM_OC_PEND_20110219.txt'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot to all of u guys.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 14:02:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680634#M1575989</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-01T14:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680635#M1575990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Miguel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the same requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing following steps:&lt;/P&gt;&lt;P&gt;1) FTP Connect&lt;/P&gt;&lt;P&gt;2) FTP_SERVER_TO_R3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I always have the error 'Command error'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me if I am missing some thing please ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;harish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Nov 2014 07:45:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680635#M1575990</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-11-22T07:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get file from Server to internal table using FTP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680636#M1575991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got the issue I was not changing the DIR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for this post !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Nov 2014 08:11:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-file-from-server-to-internal-table-using-ftp/m-p/7680636#M1575991</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-11-22T08:11:40Z</dc:date>
    </item>
  </channel>
</rss>

