Here is the code..
Retrieving the list of files in the given directory
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
NAME = PA_AFILE " Directory Path
TABLES
FILE_TBL = T_AFILES " All files...
EXCEPTIONS
ARGUMENT_ERROR = 1
NOT_FOUND = 2
OTHERS = 3.
IF SY-SUBRC 0.
* If it is run in background
IF SY-BATCH EQ C_TRUE.
WRITE: /5 'Directory cannot be opened'(039).
FL_FALSE = C_TRUE.
ELSE.
MESSAGE S000(ZZ_PA) WITH 'Directory cannot be opened'(039).
FL_FALSE = C_TRUE.
ENDIF.