Rule Definition
A number of errors can occur that result from file input-output that programmer may wish to be able to deal with in order to avoid unexpected program termination.
Run time errors can arise quite easily from a file not being available to open, or if present the data is corrupted. Furthermore, what if there is no more disk space available or not enough space has been allocated to allow for addition of new data. Other errors, such as attempting to close a file that isn't open, or to read a file opened for output only, may well derive from logical errors (that is, programming mistakes) but can be dealt with nonetheless when debugging. These kinds of errors will normally result in termination of the program run, whereas using File Status can allow the programmer to deal with any such problems without the program run stopping and returning to the operating system.
Remediation
Change the definition of data file in the ENVIRONMENT division and add a FILE-STATUS to the corresponding FD.
Violation Code Sample
SELECT TEST-FILE ASSIGN TO 'TEST-DATA.DAT'
ORGANIZATION IS SEQUENTIAL.
...
READ RECORD-IN INTO W-RECORD
...
Fixed Code Sample
SELECT TEST-FILE ASSIGN TO 'TEST-DATA.DAT'
ORGANIZATION IS SEQUENTIAL
FILE STATUS IS W-STATUS.
...
READ RECORD-IN INTO W-RECORD
IF W-STATUS = "04" THEN
DISPLAY "Over-sized record has been read"
SET REC-XS-FLAG TO TRUE
END-IF
Related Technologies
Cobol
Technical Criterion
MIPS-Reduction - focus on avoiding transaction failure
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.