A Beginner's Week in COBOL👩💻

3RD WEEK: -
Hey everyone!!!!!!!!!!!!!!! hope you all are doing well, so in this week I’ve learnt these 3 things: -
INTODUCTION
COBOL PROGRAM HIERARCHY AND DIVISIONS
COBOL Coding Sheet
\====================================================================
INTRODUCTION 👀
- COBOL stands for COMMON BUSINESS ORIENTED LANGUAGE.
- Used for writing application programs, not for system software.
- We use PDS file for writing COBOL programs, rules: -
The Record Length—>80.
The Record Format—>FB.
\====================================================================
2.A COBOL PROGRAM HIERARCHY 🌳
- The COBOL hierarchy looks like this: -
COBOL program
Division
Section
Paragraph
Sentence
Characters
\=====================================================================
2.B COBOL PROGRAM DIVISIONS 🐛
- The divisions are divided into 4 parts: -
Identification Division
- Used by the compilers and programmers to identify the program.
- Contains PARAGRAPHS, No SECTIONS. (Every line in this division is PARAGRAPH)
- Under this division, we’ll have PROGRAM-ID. (only mandatory paragraph)
- PROGRAM-ID specifies the name of the program. (1-30 characters)
Environment Division
- Consists of 2 sections: -
—>Configuration Section: provides info about the system, the program is written and
executed.
- Consists of 2 paragraphs: -
~Source Computer- used to compile the program.
~Object Computer- used to execute the program.
—>Input/Output Section: provides info about the files, used in the program.
Consists of 2 paragraphs: -
~File Control- tells COBOL, how to connect to your file, what file it should use,
how the file is setup, how it should be read.
~Input/Output Control- provides info of files used in the program.
Data Division
- used to define variables used in the program.
- this optional, required only when at least 1 var is declared under this section.
- consists of 3 sections: -
File section- used to define the structure of files. (like what each record looks like)
Working-storage section- this is where you define variables, you’ll use in your program.
- These variables keep their values as long as the program is running.
Linkage section- used when another program is calling your program or if your program is
a sub-program.
- It allows data to be passed from another program.
Procedure Division
- Contains the actual code and logic of the program.
- Begins in Area-A, and all its statements begins in Area-B.
Stop Run
- when stop run is executed, control returns to the O.S.
- doesn’t have any parameters.
- should be last executable statement.
- always be coded in main program.
- if coded in sub-programs, control returns to the main program.
Exit Program
- indicates the end of the sub-program processing and returns control to the main program.
- mainly used in COBOL sub programs.
- should be last in seq of statements.
\======================================================================
***IMP points to remember***
📌Hi COBOL in command line—→ Highlights all COBOL verbs in RED.
📌After paragraph heading, should give 1 space.
📌Whatever is written b/w IDENTIFICATION to SECURITY—→ definition of identification division.
📌Every COBOL program should end with STOP RUN.
📌Instead of STOP RUN, can write EXIT PROGRAM/GO BACK.
📌If we miss STOP RUN/EXIT PROGRAM/GO BACK, we don’ get any compilation issue, instead
result in run time abend (U4038).
\======================================================================
3.A COBOL Coding Sheet
- Also known as COBOL reference sheet.
- contains 80 columns.
1-6 columns: SEQUENCE NUMBER AREA
- first 6 characters reserved for seq number.
- automatically increases with every addition of a new line.
- COBOL compiler doesn’t consider this column as a part of code.
- this area is divided into 2 parts: -
—→ 1-3 —>current page no.
—→4-6 —>current line no. on the page.
7th column: INDICATOR AREA
- reserved for special characters like: -
—→ * (Comment Indicator)- if coded, COBOL compiler considers that line as a comment
—→ - (Continuation Indicator)- current line is the continuation of the previous line.
—→ / (Print Stopper Indicator)- the printing should start from the new page.
—→ D (Debugging Indicator)- used for debugging purposes.
8-11 columns: Area-A
- All division names, section names, system defined paragraph names, user defined
paragraph names, level numbers (01,77), declaratives, non-declaratives, FD/SD entries.
12-72 columns: Area-B
- COBOL verbs, sentences, and statements.
73-80 columns: System Generated Numbers
- reserved for system generated numbers.
- used for identification purpose.
- COBOL compiler does not consider these columns as a part of code.
Subscribe to my newsletter
Read articles from Jahnavi Puppala directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
