‎2006 Feb 09 2:38 AM
Open dataset returns sy-subrc = 8 (file does not exist)
I am having a problem reading files in a certain directory. If I move these files to the home directory (/usr/sap/RD1/DVEBMGS20 the open dataset returns sy-subrc = 0. However, when I move to the directory that has been created for interfaces /usr/sap/RD1/Interfaces/ then I cannot read the file.
my code is as follows:
*Get list of files in the directory
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
DIR_NAME = p_dir
FILE_MASK = l_file
IMPORTING
FILE_COUNTER = w_file_counter
TABLES
DIR_LIST = i_files
EXCEPTIONS
INVALID_EPS_SUBDIR = 1
SAPGPARAM_FAILED = 2
BUILD_DIRECTORY_FAILED = 3
NO_AUTHORIZATION = 4
READ_DIRECTORY_FAILED = 5
TOO_MANY_READ_ERRORS = 6
EMPTY_DIRECTORY_LIST = 7
OTHERS = 8
...
LOOP at i_files.
OPEN DATASET I_FILES-NAME FOR INPUT MESSAGE l_msg
IN text MODE ENCODING DEFAULT.
F_RCODE = sy-subrc.
IF F_RCODE <> 0.
*Error handling
...
The files are obviously in the directory as they are returned by the above function module. Is there a setting or config required to make files in this directory readable.
Our basis support is 3rd party and pretty much non-existent. I've been advised that the permissions are the problem. Not a unix expert but I figure if that was the case then I would not be able to read the files in any directory.
Urgent assistance required.
Thanks,
Jill
ENDLOOP.
‎2006 Feb 09 4:53 AM
Assuming that you are getting the list after your call to this function module, I am ruling out the permission issue. The reason for you to be not able to read the file is that the field 'I_FILES-NAME' contains only the filename, not the directory. So you have to concatenate that with the filename before you do OPEN DATASET.
LOOP at i_files.
CONCATENATE p_dir
i_files-name
INTO myfilename separated by '/'.
CONDENSE myfilename NO-GAPS.
OPEN DATASET myfilename FOR INPUT
MESSAGE l_msg
IN text MODE ENCODING DEFAULT.
F_RCODE = sy-subrc.
IF F_RCODE <> 0.
*Error handling
.....
....
Regards,
Srinivas
‎2006 Feb 09 4:22 AM
HI jill,
1. Lower case
UNIX/AIX system is CASE-SENSITIVE
2. Just make sure, the FULL NAME (WITH PATH)
is exactly matching the lower-case/upper case.
3. U can take help of AL11 tcode
to see the full file name (along with the path).
regards,
amit m.
‎2006 Feb 09 4:55 AM
Thanks Amit - my file names are correct. As shown I use a FM to return the file names found in as particular directory leaving no room for error.
‎2006 Feb 09 5:12 AM
Hi Jill,
Check if you have appropriate authorizations on the second folder like read and write.
This is a very common issue on application server.
Thanks & Regards,
Ankur
‎2006 Feb 09 4:53 AM
Assuming that you are getting the list after your call to this function module, I am ruling out the permission issue. The reason for you to be not able to read the file is that the field 'I_FILES-NAME' contains only the filename, not the directory. So you have to concatenate that with the filename before you do OPEN DATASET.
LOOP at i_files.
CONCATENATE p_dir
i_files-name
INTO myfilename separated by '/'.
CONDENSE myfilename NO-GAPS.
OPEN DATASET myfilename FOR INPUT
MESSAGE l_msg
IN text MODE ENCODING DEFAULT.
F_RCODE = sy-subrc.
IF F_RCODE <> 0.
*Error handling
.....
....
Regards,
Srinivas
‎2006 Feb 09 5:17 AM
Thanks Srinivas. Haven't tested it yet but you are absolutely correct. Explains why I can read files in the home directory - you only have to enter the file name and SAP assumes the file is in the home directory. If the file is elsewhere you have to specify the full path.
‎2006 Feb 09 5:29 AM
You are welcome. I used this function module and that is what I had to go through. The NAME field is only 40 characters in length, so the directory is not included as part of that.
Actually the problem with this function module is that it is a basis function module for transport related files. So it checks for certain basis admin authorizations in the code. Apart from that, you still need access rights to the underlying unix directory.
By the way, having access to one unix directory does not automatically guarantee you that it is universal on that server. Unix administrators can control the access to the minutest level. So you can have access to one directory but not others.
‎2006 Feb 09 5:13 AM
Hi again,
1. As already suggested,
2. If u see the FM,
it gives the list
ONLY FILE NAME (WITH OUT THE PATH)
3. In Open DATASET
we have to GIVE THE FULLL PATH + FILENAME.
(only file name would not work )
regards,
amit m.