Application Development 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: 

all files from a specified folder

Former Member
0 Kudos

Dear all,

i have to read all the files having particular date in its file name from aa folder at specifies path.

How can i get all file names from a folder.

<removed_by_moderator>

Thanks

Edited by: Julius Bussche on Sep 8, 2008 1:08 PM

10 REPLIES 10

former_member156446
Active Contributor
0 Kudos

AT SELECTION_SCREEN on FIELD REQUEST.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

EXPORTING

directory = ' '

filemask = ' '

IMPORTING

serverfile = p_afile

EXCEPTIONS

canceled_by_user = 1

OTHERS = 2.

0 Kudos

but i dont require F4 help..i want to upload in program itself...

0 Kudos

playing with file mask like * sy-datum *.. should help you..

I doubt if it can be automatically..

Former Member
0 Kudos

Try using FM: EPS_GET_DIRECTORY_LISTING

Regards

Eswar

Former Member
0 Kudos

You can use the following method:

DATA direc TYPE string.

data file_count TYPE i.

CALL METHOD cl_gui_frontend_services=>directory_list_files

EXPORTING

directory = direc

CHANGING

file_table = it_files

count = file_count.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

'direc' is a variable which has the path of the directory.

'it_files' is an internal table of any type.

The method returns all the filenames in the directory 'direc' in the table 'it_files'. Variable 'FIle_count' contains the number of files in the directory. Hope it helps

<removed_by_moderator>

Regards

Vidhya

Edited by: Julius Bussche on Sep 8, 2008 1:05 PM

0 Kudos

Thanks Vidhya,

I tried this method by giving directory name as /usr/sap/D62/DVEBMGS04/work. but it is not displaying list..

0 Kudos

Hi,

The method that I gave before is to get the filenames in a directory which is present in the local machine say 'D:\sap' . To get the file names from the application server, try the following FM:

Data RFC_DESTINATION LIKE RFCDES-RFCDEST.

Data DIRECTORY LIKE EPSF-EPSDIRNAM.

Data FILE_MASK LIKE EPSF-EPSFILNAM DEFAULT SPACE.

Data REMOTE_DIRECTORY LIKE EPSF-EPSDIRNAM.

Data FILE_COUNTER LIKE EPSF-EPSFILSIZ.

Data ERROR_COUNTER LIKE EPSF-EPSFILSIZ.

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'

DESTINATION RFC_DESTINATION

EXPORTING

DIR_NAME = DIRECTORY

FILE_MASK = FILE_MASK

IMPORTING

DIR_NAME = REMOTE_DIRECTORY

FILE_COUNTER = FILE_COUNTER

ERROR_COUNTER = ERROR_COUNTER

TABLES

DIR_LIST = DIR_LIST

EXCEPTIONS

SYSTEM_FAILURE = 03 MESSAGE LV_RFC_MESSAGE

COMMUNICATION_FAILURE = 04 MESSAGE LV_RFC_MESSAGE

INVALID_EPS_SUBDIR = 11

SAPGPARAM_FAILED = 12

BUILD_DIRECTORY_FAILED = 13

NO_AUTHORIZATION = 14

READ_DIRECTORY_FAILED = 17

TOO_MANY_READ_ERRORS = 22

EMPTY_DIRECTORY_LIST = 23.

IF SY-SUBRC <> 0.

MESSAGE E012 WITH SY-SUBRC DIRECTORY FILE_MASK

LV_RFC_MESSAGE

RAISING GET_DIR_LIST_FAILED.

ENDIF.

DIR_LIST is an internal table of structure EPSFILI.

Regards

Vidhya

0 Kudos

Thanks vidhya,,,

but for class method i am not able to use filter.....if i set like '.xls' then also it shows all the files...

Former Member
0 Kudos

Hi

Use "RZL_READ_DIR" Function Module

call function 'RZL_READ_DIR'

exporting

name = p_file " Give Application server directory

srvname = ' '

tables

file_tbl = lt_file " this internal table having list of file names

exceptions

argument_error = 1

not_found = 2

send_error = 3

system_failure = 4

others = 5.

0 Kudos

Pls check the thread's date before posting.

PS:These thread has been updating by mods to maintain the forum quality.

Cheers