Skip to Content
author's profile photo Former Member
Former Member

Function Module

I have need of a function module that finds a file in directory on file system of BW.

thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Nov 28, 2005 at 05:09 PM

    Hi Welcome to SDN,

    I don't think there is a FM for that.

    regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 28, 2005 at 05:16 PM

    Antonio Brudaglio

    Welcome to SDN !!!!!

    Take a look at the Class CL_GUI_FRONTEND_SERVICES.

    Some of the methods are useful would be :

    1. GET_SYSTEM_DIRECTORY

    2. GUI_UPLOAD

    3. DIRECTORY_LIST_FILES

    Thanks,

    Kam

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2005 at 05:22 PM

    Hi,

    I don't know if exit a standard FM, but you can build one custom that uses external command (un a linux enviorement you could use th command whereis). For external opereting system command you can see the SM69 transaction.

    I hope it can help you.

    Bye

    enzo

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 28, 2005 at 05:50 PM

    I assume you want a server side directory listing. I had to write my own class to do this. It uses Kernel calls (use with caution!) to read the server directory.

    method get_directory_listing.
    *@78QImporting@	I_DIR_NAME	TYPE CSEQUENCE	
    *@78QImporting@	I_FILE_MASK	TYPE EPSFILNAM  DEFAULT SPACE	File Name
    *@79QExporting@	E_DIR_LIST	TYPE T_ZES_EPSFILI	
    
      data: begin of file,
            dirname(175) type c, "name of directory. (possibly truncated.)
            name(175)    type c, " name of entry. (possibly truncated.)
            type(10)     type c, " type of entry.
            len(16)      type p, " length in bytes.
            owner(8)     type c, " owner of the entry.
            mtime(6)     type p, " last modification date, seconds since 1970
            mode(9)      type c, " like "rwx-r-x--x": protection mode.
            errno(3)     type c,
            errmsg(40)   type c,
          end of file.
      field-symbols: <wa_dir_list> like line of e_dir_list.
      data: error_counter type i.
    
    * get directory listing
      call 'C_DIR_READ_FINISH'                  " just to be sure
            id 'ERRNO'  field file-errno
            id 'ERRMSG' field file-errmsg.
    
      call 'C_DIR_READ_START'
            id 'DIR'    field i_dir_name
            id 'FILE'   field i_file_mask
            id 'ERRNO'  field file-errno
            id 'ERRMSG' field file-errmsg.
    *  if sy-subrc <> 0.
    *    raise read_directory_failed.
    *  endif.
    
      do.
        clear file.
        call 'C_DIR_READ_NEXT'
              id 'TYPE'   field file-type
              id 'NAME'   field file-name
              id 'LEN'    field file-len
              id 'OWNER'  field file-owner
              id 'MTIME'  field file-mtime
              id 'MODE'   field file-mode
              id 'ERRNO'  field file-errno
              id 'ERRMSG' field file-errmsg.
    
        if sy-subrc = 0.
          append initial line to e_dir_list assigning <wa_dir_list>.
          <wa_dir_list>-size = file-len.
          <wa_dir_list>-name = file-name.
          if file-type(1) = 'f' or              " regular file
             file-type(1) = 'F' or
             file-type(1) = 'd'.
    *       add 1 to file_counter.
            if file-type(1) = 'f'.
              <wa_dir_list>-rc   = 0.
            else.
              <wa_dir_list>-rc = 1.
            endif.
          endif.
        elseif sy-subrc = 1.
          exit.
        else.
          if error_counter > 1000.
            call 'C_DIR_READ_FINISH'
                  id 'ERRNO'  field file-errno
                  id 'ERRMSG' field file-errmsg.
    *        raise too_many_read_errors.
            exit.
          endif.
          add 1 to error_counter.
        endif.
      enddo.
    
    
    endmethod.

    My exporting parameter is a table type for a structure that I copied from EPSFILI. I made the filename and filesize parameters larger:

    Original:

    Filename type CHAR 40

    Filesize type INT4

    Copy:

    Filename type CHAR 175

    Filesize type FLTP Len 16 Decimal 16

    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.