Skip to Content
avatar image
-2
Former Member

File is not open in READ DATA SET

Hi folks.

I have the next code:

DATA: l_text TYPE String.

lv_file = '/repo/FI/exit/ACCESS_FILE.TXT'.

TRY.
OPEN DATASET lv_file FOR INPUT IN TEXT MODE ENCODING DEFAULT WITH SMART LINEFEED.
CATCH cx_sy_file_authority.
      g_message = 'No authorization'.
ENDTRY.

READ DATASET lv_file INTO l_text.------>ERROR

When I try read dataset, there are an error in this point with the next description:

When accessing the file "/repo/FI/exit/ACCESS_FILE.TXT", the system recognized that this file is not open. Therefore, the file cannot be accessed.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • May 03, 2017 at 05:38 AM

    There are other exceptions to handle, also check sy-subrc. Try to add the MESSAGE msg option to the OPEN DATASET statement to get the actual error during open: does the file exist, is it complient with the required options?

    Add comment
    10|10000 characters needed characters exceeded

  • May 03, 2017 at 04:57 AM

    Hi,

    Can you please share what is the error coming?

    Regards,

    Mangesh

    Add comment
    10|10000 characters needed characters exceeded

  • May 03, 2017 at 10:39 AM

    Hi,

    Use this statement instead of catching one exception.

    OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE msg.

    if msg is initial u can proceed reading the file.

    Regards,

    Priyanka.

    Add comment
    10|10000 characters needed characters exceeded