Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Method to read directory from App.server

Former Member
0 Likes
1,556

Hi Experts,

Is there any SAP defined method available to read a directory from App.server?

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,212

Use the Below function module:

DATA: lcl_directory TYPE char128.

lcl_directory = '/local/data/interface/A28/DM/OUT'.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

EXPORTING

directory = lcl_directory

filemask = c_mask

IMPORTING

serverfile = p_f2

EXCEPTIONS

canceled_by_user = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE e000(zmm) WITH text-039.

  • flg_app = 'X'.

ENDIF.

11 REPLIES 11
Read only

Former Member
0 Likes
1,212

Hi

Check this FM

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.

For reading a directory on Appl server.

Regards,

Raj

Read only

Former Member
0 Likes
1,212

You can use the FM <b>"DX_FILE_READ"</b> to read files from application server.

Read only

Former Member
0 Likes
1,212

use the trabsaction AL11...

IT WILL LIST THE DIRECTORIES

REGARDS

LOKESH

Read only

Former Member
0 Likes
1,212

if u r looking for Reading the files from directory chk this thread

Read only

Former Member
0 Likes
1,213

Use the Below function module:

DATA: lcl_directory TYPE char128.

lcl_directory = '/local/data/interface/A28/DM/OUT'.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

EXPORTING

directory = lcl_directory

filemask = c_mask

IMPORTING

serverfile = p_f2

EXCEPTIONS

canceled_by_user = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE e000(zmm) WITH text-039.

  • flg_app = 'X'.

ENDIF.

Read only

0 Likes
1,212

Hi ,

I am aware of all these FMs.But the directory path which i will get can contain any n.of characters.In all these FMs the path is limited to certain length.

That's y i am asking is there any method available to read directory from App.server.which contains directory path as type string..

Any suggessions on this will be great full to me.

Read only

0 Likes
1,212
chk this    EPS_GET_DIRECTORY_LISTING

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
    EXPORTING
      dir_name                     = l_dirname
      file_mask                    = l_filemask
* IMPORTING
*   DIR_NAME                     =
*   FILE_COUNTER                 =
*   ERROR_COUNTER                =
    TABLES
      dir_list                     = pi_filelist
 EXCEPTIONS
   invalid_eps_subdir           = 1
   sapgparam_failed             = 2
   build_directory_failed       = 3
   no_authorization             = 4
   read_directory_failed        = 5
   too_many_read_errors         = 6
   empty_directory_list         = 7
   OTHERS                       = 8
            .
Read only

0 Likes
1,212

Here is application server browser program.



report zrich_0001 .

data: begin of itab occurs 0,
      rec(1000) type c,
      end of itab.
data: wa(1000) type c.

data: p_file type localfile.
data: ifile type table of  salfldir with header line.

parameters: p_path type salfile-longname
                    default '/usr/sap/TST/DVEBMGS01/data/'.


call function 'RZL_READ_DIR_LOCAL'
     exporting
          name           = p_path
     tables
          file_tbl       = ifile
     exceptions
          argument_error = 1
          not_found      = 2
          others         = 3.

loop at ifile.
  format hotspot on.
  write:/ ifile-name.
  hide ifile-name.
  format hotspot off.
endloop.


at line-selection.

  concatenate p_path ifile-name into p_file.

  clear itab.  refresh itab.
  open dataset p_file for input in text mode.
  if sy-subrc = 0.
    do.
      read dataset p_file into wa.
      if sy-subrc <> 0.
        exit.
      endif.
      itab-rec = wa.
      append itab.
    enddo.
  endif.
  close dataset p_file.

  loop at itab.
    write:/ itab.
  endloop.

Regards,

Rich Heilman

Read only

0 Likes
1,212

Hi,

Thanks.But in this Fm the length of Directory name path is 60 characters.

Read only

0 Likes
1,212

The 'RZL_READ_DIR_LOCAL' function module accepts a filepath of 200 characters.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,212

Hi,

Yes, thats correct. But then a path of 60 character should be more than enough.

Best regards,

Prashant