cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the file path from application server

0 Kudos

Hi all,

I met a problem while getting the file path from application server.

The scenario is like this:

I need to implement a F4 help when user tries to download files from application server in WD environment, and the behavior should be similar as function "F4_DXFILENAME_TOPRECURSION".

Thank you very much!

Julia

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Here are some sample Kernel calls that will let you read an applicaiton server directory and its file contents

Signature:

@78\QImporting@ I_DIR_NAME TYPE CSEQUENCE

@78\QImporting@ I_FILE_MASK TYPE EPSFILNAM DEFAULT SPACE

@79\QExporting@ E_DIR_LIST TYPE ZES_EPSFILI_TBL2

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.
  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'.
        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.
        exit.
      endif.
      add 1 to error_counter.
    endif.
  enddo.

Edited by: Thomas Jung on Apr 2, 2010 7:46 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Julia,

You can use the FM RZL_READ_DIR_LOCAL to get the list of files in the application server directory.

Refer to this [link|http://www.divulgesap.com/blog.php?p=MTA3] for sample code.

Hope it helps.

Regards,

Ravi