IBM-Mainframes: COBOL Class-1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

IBM-Mainframes

COBOL Class-1
Background and History

 COBOL is an acronym for:

Common Business Oriented Language


 COBOL was developed in 1959 by the Conference on Data
Systems Languages (CODASYL).
 COBOL was designed to solve business problems
 COBOL was designed to be English-like, so that the reader, even
a non-programmer, could get an idea of what was going on in the
program, simply by reading the code.
 COBOL was designed to be portable, so that programs could be
adapted from one computer system to run on another, simply by
making a few changes in one isolated section of the code.
Background and History Contd..

 Since 1960, the American National Standards Institute


(ANSI) was responsible for developing new COBOL
standards.
 Three ANSI standards for COBOL have been
produced:
 in 1968, 1974 and 1985 (currently Using ).
 Object-oriented COBOL is the fourth edition in the
continuing evolution of ANSI/ISO standard COBOL.
Structure of COBOL Program

 The organization of a COBOL program is hierarchical. It's not


necessarily required for all of components to be present for the
hierarchical relationship to exist
.. Program
.. Division
.. Section
.. Paragraph
.. Sentence
.. Statement
.. Clause / Phrase / VERBS
.. Word (.. Character)
COBOL Program Organization (Division)

 We have four divisions in every COBOL program


IDENTIFICATION, ENVIRONMENT,DATA, and PROCEDURE.

 IDENTIFICATION DIVISION The first division of COBOL program;


used for documentation purposes.
 PROGRAM-ID is used to name the program. This is the only
paragraph that is required in the ID DIVISION.
 AUTHOR used to code the programmer's name

 INSTALLATION used to code the programmer's employer's name

 DATE-WRITTEN & DATE-COMPILED used to code the date the


program was written & compiled
 SECURITY used to code the security level of the program
Division’s Contd..

 ENVIRONMENT DIVISION Provides information on the equipment


and file used with the program and only division that may be machine-
dependent.
 Two sections: CONFIGURATION and INPUT-OUTPUT Section
 CONFIGURATION SECTION optional section is used to specify the
type of computer equipment
SOURCE-COMPUTER used to compile the program.
OBJECT-COMPUTER used to execute the program.
INPUT-OUTPUT SECTION used to specify input/output files used in
the program.
FILE-CONTROL used to associate the files to be used in the
program with specific I/O devices.
Division’s Contd..

 DATA DIVISION : Defines and describes all the data to be used in a


program/To declare variables.
 Sections: FILE, WORKING-STORAGE, LINKAGE, REPORT, and
COMMUNICATION SECTIONS
 FILE SECTION is used to define the files record layout that will be used
in the program.
 WORKING-STORAGE is used to define any data that will be used in
the program that is not part of a file section.
 LINKAGE SECTION is used in a subprogram to define data that will be
passed as arguments to the routine.
 REPORT SECTION can be used to produce standard control break driven
reports. COMMUNICATION SECTION is used for communicating
between two programs running simultaneously on a computer
Division’s Contd..

 PROCEDURE DIVISION This contains the instruction to be


executed in the program
 This division consists of a series of procedures called
paragraphs, each designed to perform a specific function.
 Paragraph Consists of a paragraph name and a series of
procedural statements designed to perform a desired function .
 Statement : An instruction.
 Sentence : A statement or series of statement ending with a
period (.)
 STOP RUN : Specifies end of the program.
COBOL Layout/COBOL Code Sheet (1 - 80)

1. 1-6 Sequence Number This area was originally designed for


entering line numbers on each individual line of code.
2. 7 Comments /Continuation This area is used to designate a
line as either a comment or a continuation for previous line
code.
• * This line is a comment.
• - This line is a continuation of the previous line.
3. 8-11 Area A This area is used to enter division headers, section
headers, paragraph names, file indicators and level 01 items.
4. 12-72 Area B This area is used to enter any statement that
doesn't go in Area A.
5. 73-80 Program Identification This area has been used by
programmers as a way to mark individual lines of code,
My First COBOL Program

 Hello world! Program


IDENTIFICATION DIVISION. ( ID DIVISION )
PROGRAM-ID. HELLOPGM. -  Max 8 character
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCRDURE DIVISION.
DISPLAY ‘HELLO WORLD!’.
STOP RUN.
This Program gives HELLO WORLD! As Output.
Thank You

You might also like