Hi All,
I have got a abap programme that picks up files and load them in production. however I am geting DATASET_NOT_OPEN, CX_SY_FILE_OPEN_MODE.
I have check the error logs st22 and found out that the programme still have my old file which I did run a month ago open.
Have anyone come accross this issue and if so how did you go about fixing this.
I also found fm which I think meant work to close this dataset. The code below for your review
I prefer not to write below abap in production if I can manuelly fix this without writing fm.
DATA:
First declare an object of type CX_ROOT.
OREF TYPE REF TO CX_ROOT,
Then declare a variable of type string.
TEXT TYPE STRING.
*Now open a dataset in a TRY-CATCH block
TRY.
OPEN DATASET '/USR/SAP/TRANS/ECC1/ETC/B12008.TXT' FOR OUTPUT
IN TEXT MODE ENCODING DEFAULT
Then in the catch block instantiate the Object.
CATCH CX_SY_FILE_OPEN INTO OREF.
Now in 'CATCH' block use the TEXT variable to get the TEXT from the Object.
TEXT = OREF->GET_TEXT( ).
*Now if the TEXT is not initial that means the file is already opened
*else it is not opened and we have to open it
IF TEXT IS NOT INITIAL.
If open then we can close the file
CLOSE DATASET '/USR/SAP/TRANS/ECC1/ETC/B120080627112.TXT'.
ENDIF.
ENDTRY.
Regards J