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

Problem reading a directory on a server

Former Member
0 Likes
5,694

Good morning to all my problem is I have to read a file to upload information, the problem was I have no file name and I have to upload everything I files that are inside the folder, the file has a naming txt XXX #######. the first three values do not vary over the other are numerous and vary depending on the date and time, adding the program should work in a job and would like to know if I can to help see I get the name of the file that is inside the folder which is in a thanks and best served

8 REPLIES 8
Read only

Former Member
0 Likes
2,479

From the presentation or application server?

Rob

Read only

Former Member
0 Likes
2,479

Try to put that in selection screen whatever file name to be read from folder.

If that is not possible then you will need to move the uploaded file to some other folder'XXX' and keep always the one which is unread in ZZZ folder.

Thanks!

Read only

0 Likes
2,479

the porblem is like knowing that the files are directotio server Redeemer

Read only

0 Likes
2,479

Please make it more clear -your doubt.

Read only

PedroGuarita
Active Contributor
0 Likes
2,479

To get the files from a directory in the server use FM RZL_READ_DIR_LOCAL. Then it's quite simple to loop at the results and get the file you're looking for.

Read only

0 Likes
2,479

when you test this function by the SE37 at the address of the folder I get error NOT_FOUND

the steering is \ \ aero-ccs-file00 \ SAPDEV \ FUSO \ Entry

Read only

Former Member
0 Likes
2,479

If you are running this from your PC, and not in background, you can use TMP_GUI_DIRECTORY_LIST_FILES. It will give you file names up to 255 characters long. If you need to run this in background you could try TMP_GUI_DIRECTORY_LIST_FILES but it only returns files up to 40 characters. Good luck.

Read only

Former Member
0 Likes
2,479

Hi

You can use EPS_GET_DIRECTORY_LISTING.

Refer the code snippet as below :-



DATA:   l_check_msg(50)  TYPE c,
          l_filemask       LIKE epsf-epsfilnam.

  CONCATENATE p_sysid '*' INTO l_filemask.

  CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
       EXPORTING
            dir_name               = wa_ztsifregi-pathname
            file_mask              = l_filemask
       TABLES
            dir_list               = i_files
       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.
  IF sy-subrc NE 0.
    CASE sy-subrc.
      WHEN 1.
        l_check_msg = 'Invalid subdirectory'(005).
      WHEN 2.
        l_check_msg = 'EPS_GET_DIRECTORY_LISTING failed'(006).
      WHEN 3.
        l_check_msg = 'Build directory failed'(007).
      WHEN 4.
        l_check_msg = 'No authorization'(008).
      WHEN 5.
        l_check_msg = 'Read directory failed'(009).
      WHEN 6.
        l_check_msg = 'Too many read error'(010).
*      WHEN 7.
*        l_check_msg = 'Empty directory'(011).
      WHEN OTHERS.
        l_check_msg = 'Unexpected error from function module'(012).
    ENDCASE.

Regards

Abhii