‎2007 Nov 15 2:31 PM
How can I know if a directory is empty (without files)?
Somebody know a function? or have any idea?
Thanks a lot.
‎2007 Nov 15 2:38 PM
You can use this FM: TMP_GUI_DIRECTORY_LIST_FILES
Like:
DATA: TBL_FILES LIKE SDOKPATH OCCURS 10 WITH HEADER LINE,
TBL_DIRS LIKE SDOKPATH OCCURS 10 WITH HEADER LINE.
CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
DIRECTORY = P_DIRECTORY
TABLES
FILE_TABLE = TBL_FILES
DIR_TABLE = TBL_DIRS.
describe table tbl_Files lines sy-index.
if sy-index is initial.
* no files in the directory
endif.
Regards,
Naimesh Patel
‎2007 Nov 15 2:38 PM
You can use this FM: TMP_GUI_DIRECTORY_LIST_FILES
Like:
DATA: TBL_FILES LIKE SDOKPATH OCCURS 10 WITH HEADER LINE,
TBL_DIRS LIKE SDOKPATH OCCURS 10 WITH HEADER LINE.
CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
DIRECTORY = P_DIRECTORY
TABLES
FILE_TABLE = TBL_FILES
DIR_TABLE = TBL_DIRS.
describe table tbl_Files lines sy-index.
if sy-index is initial.
* no files in the directory
endif.
Regards,
Naimesh Patel
‎2007 Nov 15 2:55 PM
Thanks a lot .
I decided to use a class.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = 'C:HELLO'
* FILTER = '*.*'
* FILES_ONLY =
* DIRECTORIES_ONLY =
CHANGING
FILE_TABLE = LV_FILES
COUNT = SIZE
* EXCEPTIONS
* CNTL_ERROR = 1
* DIRECTORY_LIST_FILES_FAILED = 2
* WRONG_PARAMETER = 3
* ERROR_NO_GUI = 4
* NOT_SUPPORTED_BY_GUI = 5
* OTHERS = 6
.
IF SIZE IS INITIAL.
MESSAGE 'La carpeta de entrada está vacia' TYPE 'I'.
LEAVE PROGRAM.
ENDIF.