Am trying to trap all I/O errors using DECLARATIVES (see code below). I have a declarative section for each of the file processing modes (INPUT, I-O, OUTPUT, EXTEND), but when I get a "47" error (attempted read on an unopened file), none of the declarative sections get invoked and instead I get the default system action. I think this happens because the I/O is for a file that has not yet been opened, and hence there is no declarative section "active" to handle the error for the file in question.
Granted a "47" error is indicative of a program logic problem and should be pretty rare in production. Still I would like to be able to trap these errors (also "42", "47" & "48" for reporting purposes. Has anyone experienced this? and does anyone have any suggestions for handling it?
Or is this just a "hole" in the current COBOL def'n? I want to say that I've heard/read something somewhere about expanded exception facilities in the next COBOL standard. Can anyone shed any light on this?
I abend on the "READ CNTL-FILE" statement if GET-SYS-ID is PERFORM'ed when the CNTL-FILE has not been opened yet. I would rather that STD-ERROR were CALL'ed to log the error instead.
Environment is RM/Cobol 7.1 on Unix (SCO 5.0.6a).
"Code what you mean,
and mean what you code!
But by all means post your code!"
Razalas
Granted a "47" error is indicative of a program logic problem and should be pretty rare in production. Still I would like to be able to trap these errors (also "42", "47" & "48" for reporting purposes. Has anyone experienced this? and does anyone have any suggestions for handling it?
Or is this just a "hole" in the current COBOL def'n? I want to say that I've heard/read something somewhere about expanded exception facilities in the next COBOL standard. Can anyone shed any light on this?
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. MY-PROGRAM.
...
ENVIRONMENT DIVISION.
...
INPUT-OUTPUT SECTION.
SELECT CNTL-FILE
ASSIGN TO DISK
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS CF-RCD-KEY
FILE STATUS IS IO-STATUS.
...
DATA DIVISION.
FILE SECTION.
FD CNTL-FILE
DATA RECORD IS CNTL-FILE-RCD.
01 CNTL-FILE-RCD.
03 CF-RCD-KEY PIC X(08).
03 CF-RCD-DATA PIC X(72).
...
WORKING-STORAGE SECTION.
77 IO-STATUS PIC X(02).
88 IO-STATUS-IS-SUCCESSFUL VALUES "00" "02"
"05" "07".
COPY STD-ERR-DATA.
...
PROCEDURE DIVISION.
DECLARATIVES.
INPUT-ERROR SECTION.
USE AFTER STANDARD ERROR PROCEDURE INPUT.
INPUT-ERRORS.
PERFORM I-O-ERRORS.
OUTPUT-ERROR SECTION.
USE AFTER STANDARD ERROR PROCEDURE OUTPUT.
OUTPUT-ERRORS.
PERFORM I-O-ERRORS.
EXTEND-ERROR SECTION.
USE AFTER STANDARD ERROR PROCEDURE EXTEND.
EXTEND-ERRORS.
PERFORM I-O-ERRORS.
IO-ERROR SECTION.
USE AFTER STANDARD ERROR PROCEDURE I-O.
I-O-ERRORS.
ACCEPT STD-ERR-TIME-STAMP FROM DATE-AND-TIME
MOVE SIGNON-NAME TO STD-ERR-USER
MOVE IO-STATUS TO STD-ERR-STATUS
...
END DECLARATIVES.
PROCESSING SECTION.
MAIN.
...
PERFORM GET-SYS-ID
...
GET-SYS-ID.
MOVE "SYS-ID" TO CF-RCD-KEY
READ CNTL-FILE
IF IO-STATUS-IS-SUCCESSFUL
MOVE CF-RCD-DATA TO WS-SYS-ID
ELSE
MOVE "CNTL-FILE" TO STD-ERR-RESOURCE
MOVE CF-RCD-KEY TO STD-ERR-KEY
CALL STD-ERROR USING STD-ERR-DATA
STOP RUN
END-IF.
...
END PROGRAM MY-PROGRAM.
I abend on the "READ CNTL-FILE" statement if GET-SYS-ID is PERFORM'ed when the CNTL-FILE has not been opened yet. I would rather that STD-ERROR were CALL'ed to log the error instead.
Environment is RM/Cobol 7.1 on Unix (SCO 5.0.6a).
"Code what you mean,
and mean what you code!
But by all means post your code!"
Razalas