You can make use of the program status data structue (PSDS) and the %Error built in function. Positions 91-170 contains an 80 character message for the exception detected and will contain the details of the job causing any record log.
FMYFILE IF E K Disk InfDs(MyFileDs)
D* Program Status Data Structure
D PgmSts SDS
D sdsRtvExcpDta 91 170
C* Chain to the file and check for any errors…
C MyKey Chain(e) MyFile
C If %Error
C CallP FileError(sdsRtvExcpDta)
C …Normal Processing
By coding the (e) extension on the Chain you are able to trap the error. In the example I would then place a call to a sub-procedure “FileError” which would display the exception message in a window.
Hope it helps