‎2008 Nov 03 1:21 PM
Hey guys
I'm reading some files(TXT) from server with this command:
CALL 'SYSTEM' ID 'COMMAND' FIELD lv_command
ID 'TAB' FIELD lt_result-sys.
At this point i have my lt_result table filled with archives names.
They all have full permission: - rwxrwxrwx. Then i use the OPEN DATASET command to get data from each archive.
OPEN DATASET p_file FOR INPUT IN TEXT MODE.
I can perfectly read some of them but i keep getting sy-subrc = 8(The file could not be opened) at others...
Does anyone know how to solve this?
Best regards!
‎2008 Nov 03 1:54 PM
HI SY-SUBRC 8..
then it should be some thing to do with the p_file make sure you are using the same case.. the path p_file is case sensitive.... check in tr. AL11 how are the paths defined.. and get the p_file exactly the same.
‎2008 Nov 03 1:23 PM
check any open datasets prior to that. and also how you defined p_file..?
‎2008 Nov 03 1:27 PM
Vijay,
p_file LIKE rlgrap-filename.
I checked and there is no prior open dataset...
‎2008 Nov 03 1:31 PM
Vijay,
And also i'm doing this
READ DATASET p_file INTO ttp_arq11 LENGTH leng.
.....
CLOSE DATASET p_file.
TYPES: BEGIN OF i_arq,
line(999),
END OF i_arq.
DATA: leng(3) TYPE n VALUE 999.
‎2008 Nov 03 1:34 PM
what are those files which you can't open/read using the open dataset.
are they normal text files or any thing else.
‎2008 Nov 03 1:37 PM
‎2008 Nov 03 1:53 PM
i thought they are not normal ones. may be they are associated with some code page etc.
‎2008 Nov 03 1:58 PM
‎2008 Nov 03 1:54 PM
HI SY-SUBRC 8..
then it should be some thing to do with the p_file make sure you are using the same case.. the path p_file is case sensitive.... check in tr. AL11 how are the paths defined.. and get the p_file exactly the same.
‎2008 Nov 03 2:00 PM
Jay,
I think the path is correct otherwise i wouldnt be able to read other files...I get sy-subrc = 8 only with a couple of files...
‎2008 Nov 03 2:05 PM
Try opening the file using tcode cg3y .If you able we can then need to trouble shoot . if not then might be an authorization issue or file might be error. pls let us know the out come.
‎2008 Nov 03 2:16 PM
Karthik,
Do you know any other transaction to do this?
Because cg3y only accepts fields with max 60 lenght and my path has 70 lenght ( with file name included ).
‎2008 Nov 03 2:17 PM
Hi,
Try to do some exception handling while opening the dataset and reading the dataset.
something like this :
DATA : lex_file_open TYPE REF TO cx_sy_file_open,
lex_file_access TYPE REF TO cx_sy_file_access_error,
lex_file_io TYPE REF TO cx_sy_file_io,
lex_root type ref to cx_root.
* Try to open the data set and catch the appropriate exception
TRY.
OPEN DATASET l_fsap FOR OUTPUT IN BINARY MODE.
CATCH cx_sy_file_open INTO lex_file_open.
MESSAGE lex_file_open->errortext TYPE 'I'.
CATCH cx_sy_file_access_error INTO lex_file_access.
MESSAGE lex_file_access->filename TYPE 'I'.
catch CX_ROOT into lex_root... " any Other exceptions
ENDTRY.
Similarly, for read dataset also handle the exceptions. You might get the exact root cause why the files are not being read.
regards,
Advait
‎2008 Nov 03 7:44 PM
Thanks for your help guys.
Jay,
The prolem was the file's extension:
file_name.txt is different from file_name.TXT
As you said, it's case sensitive. I just changed my code to search for both cases.
Thanks a lot.
Best regards.
Edited by: Danilo Henriques on Nov 3, 2008 8:47 PM