COBOL
Introduction:-
The word COBOL is an acronym for COmmon Business Oriented Language. COBOL
is designed for developing business, typically file-oriented, applications. It
is not designed for writing systems programs. COBOL is a high-level programming
language first developed by the CODASYL Committee (Conference on Data Systems Languages) in 1960.
History:-
The first COBOL compiler
became available in early 1962. The next version with some new additions was
published in 1965. In August 1968 a standard version of the language was
approved by the American National
Standard Institute (ANSI). This standard version was again modified in
1974 and is known as ANSI-74 COBOL or COBOL -74.
Importance of COBOL Program:-
COBOL was the first widely used
high-level programming language. It is an English-like language which is user
friendly. All the instructions can be coded in simple English words.
·
COBOL
is also used as a self-documenting language.
·
COBOL
can handle huge data processing.
·
COBOL
is compatible with its previous versions.
·
COBOL
has effective error messages and so, resolution of bugs is easier.
Features of Cobol
Program:-
1.
Standard Language :- COBOL
is a standard language that can be compiled and executed on machines such as
IBM AS/400, personal computers, etc.
2.
Business Oriented :- COBOL
was designed for business-oriented applications related to financial domain,
defense domain, etc. It can handle huge volumes of data because of its advanced
file handling capabilities.
3.
Robust Language :- COBOL
is a robust language as its numerous debugging and testing tools are available
for almost all computer platforms.
4.
Structured Language :- Logical control
structures are available in COBOL which makes it easier to read and modify.
COBOL has different divisions, so it is easy to debug.
Format of COBOL Program:-
COBOL programs are written in
coding sheets. There are 80 columns in a line of the coding sheet. The page number is coded in
columns.
Column Field
1-3
Page Number
4-6
Line Number (1-6 Sequence Number)
7
Continuation / Comment
8-11 A
– Margin / Area A
12-72 B-
Margin /Area B
73-80
Identification
In COBOL there are two types of
entries known as margin A and margin B entries.
Margin A entries
start from column 8, 9, 10 or 11 and margin B entries start from column 12
or anywhere
after 12. An asterisk (*) in column 7 indicates a comment line and the entry is
not compiled to produce object code.
Structure
of COBOL Program:-
A COBOL program
structure consists of divisions as shown in the following image:
·
Sections are the logical subdivision of program
logic. A section is a collection of paragraphs.
·
Paragraphs are the subdivision of a section or
division. It is either a user-defined or a predefined name followed by a
period, and consists of zero or more sentences/entries.
·
Sentences are the combination of one or more
statements. Sentences appear only in the Procedure division. A sentence must
end with a period.
·
Statements are meaningful COBOL statements that
perform some processing.
·
Characters are the lowest in the hierarchy and cannot
be divisible.
The COBOL program
consists of the following Divisions:-
1.
Identification Division
2.
Environment Division
3.
Data
Division
4.
Procedure Division
1 . Identification
Division :-
The details about the
author, date of writing the program etc will be specified. 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.
2 . Environment
Division :-
The details about the computer environment
under which the program was written and compiled etc will be notified. 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.
3. Data Division :- The variables
that are used by the program will be defined and it is
an
important division for 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 a program starts execution.
· Linkage
section is used
to describe the data names that are received from an external program.
4.Procedure Division:- All the programming statements (Executable
Cobol statements) will be written and it is the most important division. 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.
0 comments:
Post a Comment