2 things.
1st one: Are you sure the 9/004 occurs on the OPEN of "...filename.dat"? Couldn't it happen on another file?
2nd one: For diagnostic purposes, could you hardcode the assignation of "...filename.dat" instead of using the 'STRING w-directory ... filename.dat" into w-registration'? This would allow to ascertain this sporadic 9/004 RTS error occurs because of this?
Regards
Yvon