Skip to Content

parse file name from string

Hi,

I am using FTP_COMMAND to get list of files from FTP server directory

  call function 'FTP_COMMAND'
    exporting
      handle        = hdl
      command       = 'ls /pub'  " << List of files in FTP dir
      compress      = compress
    tables
      data          = result
    exceptions
      command_error = 1
      tcpip_error   = 2.

I need to check whether file exist in the FTP server directory before i am going to write.

My problem after te FTP_COMMAND i am getting a result as mentioned below. So from this result i need to PARSE the filename separetely. I like to know any function module out there, it will give the filename parsed

ls /pub
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    9 40       20232        4096 May 24  2007 list
drwxrwxr-x    3 40       49           4096 Mar 31 14:57 details
-rw-rw-r      1 40       49          75597 Mar 31 13:23 yatt6010.2008022020080320.dat
-rw-rw-r      1 40       49          75597 Mar 31 13:28 yatt6010.2008022020080321.dat
226 Directory send OK.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2008 at 08:08 PM
    REPORT zz_temp.
    
    DATA l_s_unix_dir(80)    TYPE c.
    DATA l_t_unix_dir        LIKE TABLE OF l_s_unix_dir.
    DATA l_v_regex(80)       TYPE c VALUE '\S+\s+\d+\s+\d+\s+\d+\s+\d+\s+\S+\s+\d+\s+(?:\d{4}|\d+:\d+)\s+(\S+)'.
    DATA l_v_submatch(80)    TYPE c.
    
    
    l_s_unix_dir = 'drwxr-xr-x    9 40       20232        4096 May 24  2007 list'.
    APPEND l_s_unix_dir TO l_t_unix_dir.
    l_s_unix_dir = 'drwxrwxr-x    3 40       49           4096 Mar 31 14:57 details'.
    APPEND l_s_unix_dir TO l_t_unix_dir.
    l_s_unix_dir =  '-rw-rw-r      1 40       49          75597 Mar 31 13:23 yatt6010.2008022020080320.dat'.
    APPEND l_s_unix_dir TO l_t_unix_dir.
    l_s_unix_dir =  '-rw-rw-r      1 40       49          75597 Mar 31 13:28 yatt6010.2008022020080321.dat'.
    APPEND l_s_unix_dir TO l_t_unix_dir.
    
    
    LOOP AT l_t_unix_dir INTO l_s_unix_dir.
      FIND FIRST OCCURRENCE OF REGEX l_v_regex IN l_s_unix_dir SUBMATCHES l_v_submatch.
      WRITE:/ l_v_submatch.
    ENDLOOP.
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.