File error checking in COBOL

- When your program requires file processing…it is always a good idea to check the results…of the open file command to make sure…there was not any errors.…One such error might be, a file does not exist,…this is error code 35.…Here I've made a copy of the employee program…and I've just renamed it fileStatus.…I want to add code to check for an error…when I try to open the file.…In order to check for any errors when I'm opening my files…I need to add code to three parts of my program.…

The first part I need to add in the FILE-CONTROL SECTION,…I need to add a variable to my working storage…and finally in my PROCEDURE DIVISION I need to add code…to check to see what the file status was.…Let's start with a SELECT statement.…Right now I have SELECT EMPLOYEEFILE ASSIGN TO EMPFILE.DAT.…I've added blank line and now I'm going to add…the line FILE STATUS IS…and I'm going to give it a name.…

I'm gonna say FILE-CHECK-KEY.…I'll need to add that name to my working storage…but the command FILE STATUS IS will write the file status…

Resume Transcript Auto-Scroll

Author

Released

12/8/2015

COBOL is an endangered language. But it once ran 80% of the world's business systems: thousands of mission-critical applications that still exist today. Some companies want to upgrade and transition their COBOL applications to more modern frameworks; others want to stick with COBOL's relatively stable platform. In either case, hiring managers are willing to pay a premium for candidates who know how to take on COBOL's challenges. For this reason, programmers are learning COBOL again.

This course is designed to help new and experienced programmers alike add COBOL (or add COBOL back) to their skill set. Peggy Fisher shows how to get a COBOL development environment up and running and how to start programming. She reviews COBOL's data types and constants, control structures, file storage and processing methods, tables, and strings. Challenges issued along the way will help you practice what you've learned.