COBOL is an acronym which stands for Common Business Oriented Language.
Structure of COBOL Program.
Sections – Block of code made up of one more paragraphs.
Paragraphs – Block of code made up of one or more sentences.
Sentences – Consists of one or more statements and is terminated by full stop.
Statements – Consists of COBOL verb and an operand or operands.
Words – Reserved, User Defined, Literals, Data Names.
There are four divisions in COBOL:
IDENTIFICATION DIVISION – Identifies Program
ENVIRONMENT DIVISION – Define computer used, defines files
SELECT INFILE ASSIGN ….
DATA DIVISION – Describe files, Define variables constants
Extended Storage Section
PROCEDURE DIVISION – functional logic
Although some of the divisions may be omitted the sequence in which the DIVISIONS are specified is fixed and must follow the pattern shown above.
Level Structure in Data Division
Level numbers : 01 – 49
: 66 77 88
Level 01 can be used to describe both elementary and group items.
Level 66 for renaming
Level 77 can be used to describe independent elementary items in working storage section and Linkage Sections, cannot use redefines
Level 88 used for conditional names
Redefines: It allows same area of memory to be referenced by more than one data item with different format and size
Renames: It allows same code to be copied multiple times with different names, and it is used for re-grouping the elementary data items in a record and which must be declared by using level number 66
Shared – Read & Write
Protected – Read but not write
Exclusive – Prevent others from writing and reading
Time Limits – Allows specifying a time limit on the suspension
Various Performs in COBOL
PERFORM PARA-1 THRU PARA-N
PERFORM PARA- 10 TIMES
PERFORM PARA-1 UNUTIL END-OF-FILE
PERFORM PARA-1 VARYING I FROM 1 BY UNTIL I > 10 AFTER PARA-2 FROM 1 BY 1 UNTIL J>5