Application Development 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: 

CX_SY_FILE_OPEN_MODE - DATASET_NOT_OPEN in background job

ramiwal_dsilva
Participant
0 Kudos

Hello Team,

Im facing a strange issue.

I run a background job that requires me to write some line records on to a file on a given folder in the Application server in AL11.

I have the below code.

OPEN DATASET pv_targt FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE lv_message.

IF sy-subrc eq o.

Loop at xxx

TRANSFER pw_data TO pv_targt.

CLEAR:pw_data

.EndLoop.

close dataset pv_targt

else.

WRITE:/ 'Could not create file', lv_message.

endif.

The file is created perfectly fine when the program is run in foreground.

But when I run in background, the error is always invoked.

and lv_message is populated as = no such file or directory.

But this is very much a valid path, and it works perfectly in foreground.

Can someone help?

1 REPLY 1

iftah_peretz
Active Contributor
0 Kudos

Hey,

The catchable exception CX_SY_FILE_OPEN (without the word MODE that appears in the header/title of the question) indicates that the file is already open.