COBOL – Programming Language
What is COBOL Programming?
COBOL is a programming language that reads like regular English and is often used for business and administrative purposes. The name means Common Business Oriented Language . COBOL is referred to as a legacy language, which means it is in a format that is no longer used or supported by new systems.
History of COBOL
COBOL has been around since 1959, when it was developed by the Conference on Data Systems Languages (CODASYL). It was one of the first high-level programming languages created. COBOL is run on the mainframe as well as on the PC.
It was during the 1980’s that some small businesses moved some of their mainframe COBOL programs to PC. But, this was no simple task. In the 1990’s, COBOL was widely considered a thing of the past. It was obsolete, mainly because technology was becoming more object-oriented and moving away from the mainframe.
Programming in COBOL
To begin writing a COBOL program, you need a compiler and a location to write the program. You can write COBOL programs in text editors like Notepad or Notepad++. Once it is written, the program must be compiled to check for errors and converted into a language that the computer can read.
Divisions of COBOL
The first thing to understand is that COBOL is divided into four divisions. The divisions are created in the program in this order:
- Identification Division
- Environment Division
- Data Division
- Procedure Division
It is the first and only mandatory division of every COBOL program. The programmer and the compiler use this division to identify the program. In this Division, PROGRAM-ID is the only mandatory paragraph. PROGRAM-ID specifies the program name that can consist 1 to 30 characters.
Environment division is used to specify input and output files to the program. It consists of two sections:
- Configuration section provides information about the system on which the program is written and executed.
- It consists of two paragraphs
- Source computer : System used to compile the program.
- Object computer : System used to execute the program.
- Input-Output section provides information about the files to be used in the program.
- It consists of two paragraphs:
- File control : Provides information of external data sets used in the program.
- I-O control : Provides information of files used in the program.
Data division is used to define the variables used in the program. It consists of four sections:
- File section is used to define the record structure of the file.
- Working-Storage section is used to declare temporary variables and file structures which are used in the program.
- Local-Storage section is similar to Working-Storage section. The only difference is that the variables will be allocated and initialized every time program a starts execution.
- Linkage section is used to describe the data names that are received from an external program.
Procedure division is used to include the logic of the program. It consists of executable statements using variables defined in the data division. In this division, paragraph and section names are user-defined.
There must be at least one statement in the procedure division. The last statement to end the execution in this division is either STOP RUN which is used in the calling programs or EXIT PROGRAM which is used in the called programs.