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

Read local folder, return filenames into internal table

Former Member
0 Likes
3,565

Assume I have 3 files in c:\abc folder:

a1.xls

a2.xls

a6.xls

Is there a fm or code sample to pass in folder name (ie c:\abc) and returns a1.xls, a2.xls and a6.xls into internal table?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,058

Hi,

Go through these FMs:

TMP_GUI_DIRECTORY_LIST_FILES

TMP_GUI_READ_DIRECTORY

RZL_READ_DIR

Do search on them, you will get the details.

Cheers.

Assume I have 3 files in c:\abc folder:

a1.xls

a2.xls

a6.xls

Is there a fm or code sample to pass in folder name (ie c:\abc) and returns a1.xls, a2.xls and a6.xls into internal table?

3 REPLIES 3
Read only

GauthamV
Active Contributor
0 Likes
1,058

Use this function module.

RZL_READ_DIR_LOCAL

Read only

Former Member
0 Likes
1,059

Hi,

Go through these FMs:

TMP_GUI_DIRECTORY_LIST_FILES

TMP_GUI_READ_DIRECTORY

RZL_READ_DIR

Do search on them, you will get the details.

Cheers.

Read only

Former Member
1,058

Use Class CL_GUI_FRONTEND_SERVICES Method DIRECTORY_LIST_FILES to get list of file in a folder . FILE_TABLE will give the table with list of files

data: begin of itab ,
        file(26) type c,
      end of itab.
data: tab type table of itab.

data : cnt type i.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
  EXPORTING
    DIRECTORY                   = 'C:\temp'
*    FILTER                      = '*.*'
*    FILES_ONLY                  =
*    DIRECTORIES_ONLY            =
  CHANGING
    FILE_TABLE                  = tab
    COUNT                       = cnt
*  EXCEPTIONS
*    CNTL_ERROR                  = 1
*    DIRECTORY_LIST_FILES_FAILED = 2
*    WRONG_PARAMETER             = 3
*    ERROR_NO_GUI                = 4
*    NOT_SUPPORTED_BY_GUI        = 5
*    others                      = 6
        .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.