Skip to Content
author's profile photo Former Member
Former Member

OPEN DATASET Not raising Exceptions (CX_SY_FILE_OPEN )

Hi Experts

I've got a Method that tests the users permissions. It is basically based on the same principle as the FM PFL_CHECK_DIRECTORY.
My problem however lies with: When I call this method from a test program and stop it after the OPEN DATASET command and then have one of my
Colleagues do the same then there is no exception raised on his side to let him know that the file is already open. I've tried various ways but with no avail,
Has anybody else come across this before and how do I solve it?

Below is the ways that I have tried:

TRY .

OPEN DATASET lv_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

CATCH cx_root.

" Handle Exception

ENDTRY.

TRY.

OPEN DATASET lv_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

CATCH cx_sy_file_open INTO lo_err.

lv_string = lo_err-get_text( ).

" Handle Exception

ENDTRY.

OPEN DATASET lv_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE lv_msg.

IF sy-subrc <> 0.

MESSAGE lv_msg TYPE 'I'.

ENDIF.

NONE of these work :-( All of them open the file from my test program, the Class Builder and my Colleagues machine and none of the
OPEN DATASET Statements Raise the cx_sy_file_open Exception...

Am I Missing something somewhere?

Any help would be appreciated.

Thanks

Vic

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 14, 2012 at 10:31 AM

    Hello Vic,

    I think the program is behaving as expected, opening a file in a separate session won't raise the CX_SY_FILE_OPEN exception.

    This is documented in the SAP documentation:

    The file must not yet be open in the current program; otherwise a handleable exception is raised.

    You will have to adopt a work around to which this. A simple way of doing this is to use lock-objects 😊

    BR,

    Suhas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2012 at 10:52 AM

    Check below link, as per this exception handelling is catchable in unicode system only, so is your system is unicode compatible?

    http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET.htm

    Also check with sy-subrc if it works.

    Otherwise at last you need to create lock objects,http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET.htm

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Gegan
      To answer your question: yes our system is Unicode enabled...
      I've looked into the links previously as well, What is really worrying me now is that when two users execute the same program from different locations/offices does this mean that both will be able to write data to the same file causing duplicated data, just because this standard call does not raise an exception when the file is already open? That is a pretty serious problem...Is the only way then by creating Lock Objects? Regards Vic

      T

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.