12-14-2012 10:20 AM
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
12-14-2012 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
12-14-2012 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
12-14-2012 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
12-14-2012 11:09 AM
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