Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Can't read with OPEN DATASET

danilo_henriques
Explorer
0 Likes
2,792

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!

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
2,707

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.

13 REPLIES 13
Read only

Former Member
0 Likes
2,707

check any open datasets prior to that. and also how you defined p_file..?

Read only

0 Likes
2,707

Vijay,

p_file LIKE rlgrap-filename.

I checked and there is no prior open dataset...

Read only

0 Likes
2,707

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.

Read only

0 Likes
2,707

what are those files which you can't open/read using the open dataset.

are they normal text files or any thing else.

Read only

0 Likes
2,707

Normal text files: name_of_file.txt

Read only

0 Likes
2,707

i thought they are not normal ones. may be they are associated with some code page etc.

Read only

0 Likes
2,707

Vijay,

What do you mean by code page?

Read only

former_member156446
Active Contributor
0 Likes
2,708

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.

Read only

0 Likes
2,707

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...

Read only

0 Likes
2,707

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.

Read only

0 Likes
2,707

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 ).

Read only

0 Likes
2,707

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

Read only

0 Likes
2,707

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