Depending on the SAP version and release level, we can use function module PFL_CHECK_DIRECTORY to check whether a given SAP directory exists in SAP R/3 system or not.
The details about this function module PFL_CHECK_DIRECTORY can be found using transaction code SE37 or SE80.

As we can see, the various fields are Directory, Write_Check, Filname and Directory_long.
| Parameter | Reference | Length | Default | Optional | Text |
|---|---|---|---|---|---|
| DIRECTORY | BTCH0000-TEXT80 | 80 | X | Name of directory | |
| WRITE_CHECK | BTCH0000-CHAR1 | 1 | SPACE | X | Write authorization for directory |
| FILNAME | BTCH0000-TEXT80 | 80 | SPACE | X | |
| DIRECTORY_LONG | CHAR128 | 128 | X | ||
Exceptions:
| Exceptions | Short Text |
|---|---|
| PFL_DIR_NOT_EXIST | Directory does not exist |
| PFL_PERMISSION_DENIED | No write authorization for directory |
| PFL_CANT_BUILD_DATASET_NAME | Temporary file cannot be generated |
| PFL_FILE_NOT_EXIST | |