2004 Oct 04 5:24 PM
Hi,
What is the best way to check directory existence in the application server?
'OPEN DATASET gv_dir.' seems to work in HP-UNIX, however as far as I know OPEN DATASET is for files.
I checked FM 'EPS_GET_DIRECTORY_LISTING' it calls kernel to check dir existence, which is not s good idea to use it in customer programs:
CALL 'C_DIR_READ_START'
ID 'DIR' FIELD DIR_NAME
ID 'FILE' FIELD FILE_MASK
ID 'ERRNO' FIELD FILE-ERRNO
ID 'ERRMSG' FIELD FILE-ERRMSG.
IF SY-SUBRC <> 0.
RAISE READ_DIRECTORY_FAILED.
ENDIF.
Any idea?
Thanks in advance,
Peter
2004 Oct 04 5:47 PM
Hi Peter
Although it uses kernel function call, you can use it if otherwise is not stated in official documentation. Because the call is wrapped by a usual function module, its availability is somehow guaranteed I think.
Moreover, I guess there are lots of ABAP developers who directly use kernel function calls although it is not so recommended.
*--Serdar
Hi Peter
Although it uses kernel function call, you can use it if otherwise is not stated in official documentation. Because the call is wrapped by a usual function module, its availability is somehow guaranteed I think.
Moreover, I guess there are lots of ABAP developers who directly use kernel function calls although it is not so recommended.
*--Serdar
2004 Oct 04 5:47 PM
Hi Peter
Although it uses kernel function call, you can use it if otherwise is not stated in official documentation. Because the call is wrapped by a usual function module, its availability is somehow guaranteed I think.
Moreover, I guess there are lots of ABAP developers who directly use kernel function calls although it is not so recommended.
*--Serdar
2004 Oct 04 8:54 PM
OPEN DATASET FOR OUTPUT should work since it will give an error if the file you tried to create in a server directory can't be created because of invalid directory/path. You can use dummy filename.
2007 Jul 18 3:22 AM
Hi,
You can check the directory in the application server using the transaction AL11.
Also as said by one of the friend it gives a short dump 'DATASET_CANT_OPEN' if there is no such directory in the application server (while using OPEN DATASET).
I hope this helps.
2007 Jul 18 3:44 AM
You can use OPen dataset,but if you want to validate at At selection-screen then we need to use diffrent logic,i have written the code as below for one of my program.
Below is the code to get all the files falling in the directory...... .
data: begin of t_tabl occurs 0,
line(132),
end of t_tabl,
data: lc_command(100) type c.
Get all the file name falling under specified directory...
lc_command(3) = 'ls '.
lc_command+3(45) = p_dir. " Directory of file path
call 'SYSTEM' id 'COMMAND' field lc_command
id 'TAB' field t_tabl-sys.
Check any files exits in the directory.......................
if t_tabl[] is initial.
message e006 with 'No files exist in the specified directory ' p_dir.
endif.
Above step will give you the all the fiels falling under the directory specified. But you have to loop through the internal table t_tabl to find the required files for eg: if you know the start few letters of the file name which are going to be constant always....like CWD_CNF*..
To delete the files.
loop at t_tabl.
lc_command(3) = 'rm'.
lc_command+3(45) = t_tabl-line.
call 'SYSTEM' id 'COMMAND' field lc_command
id 'TAB' field t_tabl-sys.
endloop.
Thanks
Seshu
2007 Jul 18 4:00 AM
Hello Peter,
This function module is the best !
PFL_CHECK_DIRECTORY
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |