COBOL

COBOL is an acronym which stands for Common Business Oriented Language.

Structure of COBOL Program.

  • Program

  • Divisions

  • 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
Program-ID. <name>.

ENVIRONMENT DIVISION – Define computer used, defines files
Configuration Section.
Source-Computer. T16.
Object-Computer. T16.
Input-Output Section.
File-Control
SELECT INFILE ASSIGN ….
…..
Receive-Control
DATA DIVISION – Describe files, Define variables constants
File Section.
FD
Working-Storage Section
Extended Storage Section
Linkage Section

PROCEDURE DIVISION – functional logic
Declaratives.
Main-Program

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

File Access:
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

File Organization:
Sequential
Indexed
Relative

Access Mode:
Sequential
Random
Dynamic

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
PERFORM IN-LINE

Leave a Reply

Your email address will not be published. Required fields are marked *