Introduction to COBOL
- COBOL stands for COmmon Business Oriented Language.
- It was developed in 1959 by a group of computer professionals known as Conference on Data System Language (CODASYL).
- This language is used for writing an application program. It cannot be used to write system software.
- The American National Standards Institute (ANSI) developed a standard of the language in 1968.
- After being standardized in 1968, it has since been revised number of times.
- Object-Oriented COBOL was released in 2002.
Features of COBOL
- It is a standard language which is executed and compiled on machines like personal computer, IBM etc.
- For developing business applications COBOL is designed.
- Because of its advanced file handling capability it can handle huge volume of data.
- Logical control structure in COBOL makes it easier to read and modify.
- Various debugging and testing tools are accessible in all computer platforms so it is a robust language.
- It is easy to debug because it has different divisions.
Advantages of COBOL
- It is the first widely used high level programming language.
- It is compatible with its past versions.
- COBOL can handle huge data processing.
- Resolution of bugs is easier because it has an effective error message.
- It is used as a self documenting language.
Program structure of COBOLVarious divisions in COBOL program structure are as follows:
- Sections are the logical subdivision of program logic.
- Section is the collection of paragraphs.
- Paragraphs are the subdivision of a selection.
- It is either user defined or predefined name followed by a period and it also includes zero or more sentences.
- Sentences are the combination of one or more statements.
- They occur only in the procedure division.
- A sentence must end with a period(.).
- These are the meaningful COBOL statements and they perform some processing.
- These are the lowest in the hierarchy and they cannot be divided.
COBOL program includes four divisions
1) Identification Division
2) Environment Division
3) Data Division
4) Procedure Division
1. Identification Division
2. Environment Division
- It is the first and compulsory division of every COBOL program.
- The compiler and the programmer uses this division to recognize the program.
- PROGRAM-ID is the only compulsory paragraph in this division.
- It identifies the program name which contain characters.
It is used to identify input and output files to the program.
Environment division includes two sections:
a) Configuration section –
It gives the information about the system on which the program is written and executed.
Configuration section includes two paragraphs:
i) Source computer -
This system is used to compile the program.
ii) Object computer -
This system is used to execute the program.b) Input-Output sections
It gives the information of files which are used in the program.
It includes two paragraphs:
i) File control –
It gives the information about the external data sets used in the program.
ii) I-O control –
It gives information of files used in the program.
3) Data Division
It is used to define the variables used in the program.
It includes four sections:
a) File section -
It is used to define the record structure of the file.
b) Working storage section -
This section is used to declare the temporary variables and file structures that are used in the program.
c) Local-storage section -
It is similar to the local working storage section. The difference is that the variables are initialized and allocated every time when the program starts execution.
d) Linkage section -
It describes the data names received from the external storage.
4) Procedure Division
- It is used to include the logic of the program.
- It includes executable statements using variable defined in the data division.
- Paragraphs and the section names are user defined in this section.
- It should be at least one statement in the the procedure division.
- The last statement of the program is STOP RUN(used in the calling programs) or EXIT PROGRAM. (used in the called program)