260 likes | 898 Views
COBOL - Introduction. A program - is a set of instructions that enable a computer to process data. There are two types of programsOperating System programsApplication programsOperating Systems:All programs run under the control of an operating systemThis program monitors and control the overall operation of the computerApplication programsTakes input data and converts it to meaningful output information.
E N D
1. COBOL - Structured Programming Structured programming use logical control structures to specify the order in which instructions are executed.
These structures are the same for all languages
The four logical structures are
Sequence
Selection
Iteration
Case structure
3. COBOL - History COBOL is an acronym that stands for Common Business Oriented Language.
COBOL was developed in the 1950s; and was designed for applications with large volumes of Data
To date over 50% of computer code in existence is in COBOL
4. COBOL - History COBOL’s popularity is due largely to the USA’s Department of Defense which played in leading role in standardizing the COBOL language
5. Read and understand program specifications
Draw hierarchy charts
Draw program flowcharts
Write program code
Compile a program and correct errors
Test-run the program with test data
Document the program Steps in program Development- COBOL programming context
6. There are four main divisions in a COBOL program
IDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
PROCEDURE DIVISION Divisions and Programming Area
7. The divisions are coded in a text Editor.
The divisions are coded in that particular order
Name of the division and actual word ‘DIVISION’ are coded separated by a single space
Each division plays a specific role in the COBOL program Notes to remember about Divisions
8. columns 1-6
Optional sequence number
column 7
Comment line (with an *)
(ignored by compiler)
columns 8-11
Area A (division heads, paragraphs, FD, 01entries)
columns 12-72
Area B (All other entries)
columns 73-80
Program identification(also ignored by the compiler) Rules for the Coding a COBOL program
9. Identifies the program
Example 1.0 IDENTIFICATION DIVISION
10. There are two sections in this division
Configuration section (Hardware details; this section is NOT NEEDED)
Input-Output section(File details) 2.0 ENVIRONMENT DIVISION
11. This DIVISION typically contains two sections
FILE SECTION, and
WORKING-STORAGE SECTION
File section deals with Input and Output file descriptions
FD- File description (starts in Area A)
01 - to describe the record layout (also in area A)
Working Storage section
Is the section where the input and output records are manipulated and all other variables needed are defined.
Typically contains the variables, heading lines and detail record 3.0 DATA DIVISION
12. In a COBOL program, you’ll find the following words
Words
Reserved words
User Defined words
Constants or Literals
Non-Numeric
Numeric
Figurative constants
Note: Reserve words, and User Defined words are case NON-sensitive COBOL Language Elements
13. Reserved words
See Appendix B, page 700
User Defined words (page 85)
These are data names for storage, paragraph, and section names
Examples:
EMPLOYEE-NAME-OUT
WS-END-OF-FILE-INDICATOR
Rules:
max 30 characters
A-Z, 0-9, and hyphen (-)
must start and end with A-Z, or 0-9 (paragraph ad section name are the only user defined words that are allowed to start with 0-9)
cannot begin or end with hyphen
must be at least one alphabetic character
cannot be a reserved word
COBOL Language Elements
14. Non-Numeric Literals
these are string constants
Examples:
“Summary of Loans Report”
“ABC”
Rules:
max 160 characters
quotation marks are required before and after (single or double - compiler option)
contents between the quotes are case-sensitive
COBOL Language Elements
15. Numeric Literals
these are hard-coded numbers
Examples:
12.45
-1
Rules:
max 18 digits
+, - must appear on the left of the number
COBOL Language Elements
16. X Alpha-numeric (1 byte)
9 Numeric (1 bytes)
S Operational SIGN (does not take up any space)
e.g. 05 WS-CREDIT PIC S9(3)
V Implied Decimal Point
e.g. 05 WS-SALARY PIC 9(5)V9(02) Non-Edited Picture Characters
17. Data File of SALEFILE
111111111MOOING MARTY 001451255000
222222222PATSY POTATO 450003569050
333333333ROWDY RODENT 205001259020
444444444STARING STACEY 000090000650
The File Description:
FD SALES-FILE
RECORD CONTAINS 80 CHARACTERS
DATA RECORD IS SALES-REC.
01 SALES-REC.
05 EMPLOYEE-NUM-IN PIC 9(09).
05 NAME-IN PIC X(20).
05 QUANTITY-IN PIC 9(05).
05 AMOUNT-IN PIC 9(05)V99.
05 FILLER PIC X(39)
Note the use of X and 9 and numbers in parentheses Example Input file and File Description
18. Main Memory Example Input file and File Description