COBOL History

51
1 COBOL History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. It was developed in 1959 by a group of computer professionals called the Conference on Data Systems Languages (CODASYL). Since 1959 it has undergone several modifications and improvements. In an attempt to overcome the problem of incompatibility between different versions of COBOL, the American National Standards Institute (ANSI) developed a standard form of the language in 1968. This version was known as American National Standard

description

COBOL History - PowerPoint PPT Presentation

Transcript of COBOL History

Page 1: COBOL History

1

COBOL HistoryCOBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. It was developed in 1959 by a group of computer professionals called the Conference on Data Systems Languages (CODASYL). Since 1959 it has undergone several modifications and improvements. In an attempt to overcome the problem of incompatibility between different versions of COBOL, the American National Standards Institute (ANSI) developed a standard form of the language in 1968. This version was known as American National Standard (ANS) COBOL.

Page 2: COBOL History

2

In 1974, ANSI published a revised version of (ANS) COBOL, containing a number of features that were not in the 1968 version. In 1985, ANSI published still another revised version that had new features not in the 1974 standard. The language continues to evolve today. Object-oriented COBOL is a subset of COBOL 97, which is the fourth edition in the continuing evolution of ANSI/ISO standard COBOL. COBOL 97 includes conventional improvements as well as object-oriented features. Like the C++ programming language, object-oriented COBOL compilers are available even as the language moves toward standardization.

Page 3: COBOL History

3

Areas of ApplicationCOBOL is ideally suited for the solution of business problems. For example, if a company wanted to keep track of its employees’ annual wages, COBOL would be ideal language for implementation. It is interesting to note that COBOL was the first programming language whose use was mandated by the Department of Defense (DoD).

Page 4: COBOL History

4

It’s not dead!

• millions of lines of COBOL code presently exist

• heavy need for year 2000

• new standards in ‘98

Page 5: COBOL History

5

Introduction to COBOL and Program Development

• COBOL – – COmmon Business Oriented Language

• First released in 1960 by CODASYL– Conference of Data Systems Language

• Purpose was to provide a High-Level Programming Language for the business world.

Page 6: COBOL History

6

High-Level Vs. Low-Level Languages

• High-Level Language– The program statements are not closely

related to the internal characteristics of the machine.

– Are more English-like and less cryptic– Can be easily transferred from one

• Examples– COBOL, C++, C#, Java, VB, etc.

Page 7: COBOL History

7

High vs. Low-Level Languages+

• Low-Level Language– Uses symbolic notation to represent

machine instructions– Is closely related to the internal

architecture of the machine– Cannot be transferred from, one machine

system to another• Examples:

– Machine language, Assembly language

Page 8: COBOL History

8

COBOL’s Survival

• COBOL is widely accepted

• Has been in use for over 35 years

• Many businesses have great investment in COBOL programs.

• COBOL is available on every computer platform

• Object-COBOL is available

• COBOL Versions: ’68, ’74, ’85, ’90?

Page 9: COBOL History

9

Advantages of COBOL

• COBOL was designed to be machine- independent, English-like, and self- documenting• COBOL has had ANSI support since 1960• ANSI

– American National Standards Institute• COBOL Compiler

– Translates COBOL source code into machine language

Page 10: COBOL History

10

Disadvantages of COBOL

• COBOL programs are wordy

• They are longer than those produced in most other languages

• Is not popularly employed for coding scientific applications

Page 11: COBOL History

11

Information Processing• Information Processing

– The production of information by processing data on a computer.

• Stream Input/Output– This is typical with C++, Java, VB, etc– Program reads data and assigns it to

variables• Record Input/Output

– This is typical with COBOL– COBOL groups data into fields and records

Page 12: COBOL History

12

Record Blocking

• Increases the efficiency of record I/O

• Blocking– Grouping the records transmitted from

secondary memory to the CPU as needed by the program

– Records are supplied one at a time to the program through READ statements

• The block is a physical record and each record within the block is a logical record

Page 13: COBOL History

13

Steps in the Programming Process

• Understand the Problem• Design the Program• Code the Program• Test the Program• Document the Program

Page 14: COBOL History

14

Step 1 - Understanding the Problem

• Be sure that you have a complete understanding of the purpose of the program • read the specifications

• Establish and maintain a channel of communication with the client

• Determine what the output of the program should be

• Examine the input• Determine what mathematical calculations are

needed

Page 15: COBOL History

15

Step 2 - Design the Program

• Develop the sequence of steps you will need to solve the problem

• Should not involve a computer• Tools needed are: spacing chart, flowcharts,

hierarchy charts, and pseudocode.• Make use of the top-down design approach

to problem solving

Page 16: COBOL History

16

Step 2+ -- Design Tools• Spacing chart

– Consists of rows and columns that can be used to design the appearance of a screen or a printed report

• Flowchart– A graphical representation of the steps needed to solve a problem

• Hierarch chart– Demonstrates the relationship between the paragraphs used in the program and how the solution is organized

• Pseudocode– An English-like representation of the actions needed to solve the problem.

Page 17: COBOL History

17

Step 3 - Coding the Program• Design the logic and then translate it into COBOL code• Source code

– These are the instructions you write for the computer to carry out. – It is your code before it is translated into machine language– You write source code with a text editor– A language sensitive editor helps you by placing the cursor in the correct column positions and pointing out syntax errors

• Syntax errors –caused by not using the language correctly

Page 18: COBOL History

18

Step 4 - Testing the Program

• After writing the program, you need to compile it.

• Compilation– translating the source code (program) to

machine code– This is done by the compiler

• If syntax errors show up, you should correct them and recompile until you obtain a clean compile

Page 19: COBOL History

19

Step 5–Documenting the Program

• Documentation is necessary to allow people to

figure out how to use your program and/or fix it

when future errors show up or modifications are

necessary.• Program documentation can take many forms:

– External documentation• Notes and Manuals for other programmers

– Comments lines and meaningful data names• These help with program readability and enhances

the self-documenting nature of COBOL code.

Page 20: COBOL History

20

Structured Programming

• Structured programming uses the three basic logic control structures:

– Sequence, selection, & iteration• A logic control structure is a way in which statements in a program can be executed.• Advantages offered:

– Programs appear neater and are more readable– Reliability and efficiency of programs are improved– Reduces time spent on debugging, testing, and modifying programs– Increases programmer productivity

Page 21: COBOL History

21

Top-Down Design/Programming

• Methodologies for solving large problems• Top-Down Design

– Breaks a large, complex problem into smaller,

less complex units– Also called Divide and Conquer strategy

• Top-Down Programming– The high-level modules are coded as soon as

they are designed.

Page 22: COBOL History

22

Divisions of a COBOL Program

• All COBOL programs are divided into four divisions.

• IDENTIFICATION DIVISION

• ENVIRONMENT DIVISION

• DATA DIVISION

• PROCEDURE DIVISION

• Each division has a function in the overall development and execution of the program

Page 23: COBOL History

23

IDENTIFICATION DIVISION

• Provides the computer with basic information about the program

• Has only one required entry• The division header contains the reserved

words IDENTIFICATION DIVISION• The reserved word: PROGRAM-ID is used to

name the program. • The program name is selected by the programmer.

• Periods are required at end of each division .

Page 24: COBOL History

24

IDENTIFICATION DIVISION+

• The COBOL language processor looks for periods to terminate various elements of the program.• The asterisk (*) is used to convey documentation in the program.• Comment

– The * is placed in column 7 and is ignored by the COBOL compiler.

Page 25: COBOL History

25

• Identifies the program• Example

IDENTIFICATION DIVISION

IDENTIFICATION DIVISION.PROGRAM-ID. PRGM01.

Page 26: COBOL History

26

ENVIRONMENT DIVISION

• This is the most hardware-dependent part of a

COBOL program• Defines Input and Output• Contains the INPUT-OUTPUT SECTION and the

FILE-CONTROL paragraph.• The INPUT-OUTPUT SECTION:

– Designates the data files that the program uses.– Each data file is associated with a hardware input-

output device

Page 27: COBOL History

27

• 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

INPUT-OUTPUT SECTION.FILE-CONTROL.SELECT SALES-FILE ASSIGN TO DISK.SELECT PRNT-FILE ASSIGN TO PRINTER.

Page 28: COBOL History

28

• 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

DATA DIVISION

Page 29: COBOL History

29

• 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

Page 30: COBOL History

30

• Reserved words

• User Defined words– These are data names for storage, paragraph,

and section names– Examples:

• EMPLOYEE-NAME-OUT• WS-END-OF-FILE-INDICATOR

COBOL Language Elements

Page 31: COBOL History

31

– 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

Page 32: COBOL History

32

• 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

Page 33: COBOL History

33

• 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

Page 34: COBOL History

34

• 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

Page 35: COBOL History

35

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

Page 36: COBOL History

36

Main Memory

Example Input file and File Description

Disk

SALEFLEfile

AS400 Operating

System

.

Program Executable Code

Buffer

Working Storage

ENVIRONMENT DIVISION.

INPUT-OUTPUT SECTION.

FILE-CONTROL.

SELECT SALES-FILE ASSIGN TO DISK-SALEFLE.

DATA DIVISION.

FILE SECTION.

FD 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)

Page 37: COBOL History

37

Working Storage Section

• Purpose– to save, or store temporary data for use in the

program

• Records and variables– consist of Group and Elementary items– Elementary items MUST HAVE a PIC clause– Group items may consist of one or more

elementary item, or other Group items– Group items are consider alphanumeric

always– To show groupings, LEVEL numbers are used

Page 38: COBOL History

38

Working Storage Section

– Rules:• In sequence (from smaller numbers to larger)• But don’t have to be consecutive• Also, not required to jump by any given

interval; can be random• Record level is 01 level• Valid numbers are 01 through 49 inclusive• 66, 77, 88 have special purpose usage

Page 39: COBOL History

39

Working Storage Section

– VALUE clauses are ONLY allowed in Working Storage (not allow in FILE section).

– Used to initial elementary data items– Cannot be used for group items– can take a

• literal• Figurative constant • the word ALL

Page 40: COBOL History

40

Working Storage Section– Examples:

01 WS-RPT-TITLE.

05 WS-RPT-TITLE PIC X(20)VALUE

‘SALES REPORT’.

05 WS-CHRISTMAS-DAY.

10 XMAS-YR PIC 9(04) VALUE 2002.

10 XMAS-MM PIC 9(02) VALUE 12.

10 XMAS-DD PIC 9(02) VALUE 25.

01 DRAW-LINE PIC X(133) VALUE ALL “*”.

Page 41: COBOL History

41

The PROCEDURE DIVISION• Contains the program logic processing steps• Contains procedures, which are actions to be carried out by the program• It s made up of separate modules called paragraphs.• Statements in the PROCEDURE DIVIDION begin with action verbs

Page 42: COBOL History

42

The Paragraph Name• A paragraph name is user-defined.• It must end with a period.• No blanks are allowed in the name.• Hyphens may be used to separate the words that make up the paragraph name.• Recommended to start the name with a module level number.• Following the paragraph name are COBOL statements – These designate operations to take place and thus begin with verbs.

Page 43: COBOL History

43

Overall Program Execution

• COBOL statements are not executed directly• They are converted into machine language• The statements in the program are called source code• The statements that the computer executes is called the object code• Execution of a program begins with the first statement following the PROCEDURE DIVISION and continues statement by statement until the end of the program is encountered.

Page 44: COBOL History

44

COBOL Coding Format

• The Coding form – this is divided into four major fields :

Usage ColumnsSequence numbers 1 – 6Indicator area (*,-) 7Area A (Headers) 8 – 11Area B (statements) 12 – 72Program identification 73 – 80

Page 45: COBOL History

45

Program Preparation+

• Line numbers in the program are NOT entered by the programmer. They are generated by the compiler.• Area A and Area B entries

– Columns 8 – 11 is area A– Columns 12 – 72 is area B

• These columns are significant because COBOL entries must start in specific columns.

Page 46: COBOL History

46

Page 47: COBOL History

47

Procedure Division

• Its very important to be precise while dealing with the procedure division.

• This is the only division that requires hierarchy chart, pseudocode, and program flowcharts.

• Hierarchy chart: Overview of the process.• Pseudocode: Near COBOL code without syntax.• Flowchart: Graphical representation of program

flow.

Page 48: COBOL History

48

Hierarchy Chart

• Level1

• Level2

• Level3

MAIN-RTN

HDG-RTN READ-RTN DETAIL-RTN

READ-RTN

Page 49: COBOL History

49

PseudocodeMAIN PROCESS

OPEN FILES WRITE HEADINGS READ FIRST RECORD PROCESS RECORDS UNTIL NO MORE RECORDS CLOSE FILES STOP PROCESSING

WRITE HEADINGS MOVE AND WRITE HEADING LINE 1

MOVE AND WRITE HEADING LINE 2PROCESS RECORDS MOVE AND WRITE DETAIL RECORDS

READ NEXT RECORD

Page 50: COBOL History

50

FLOWCHART

PROGRAM

FLOWSTART

STOP

READ-RTN

HDG-RTN

DETAIL-RTN

CLOSEFILES

OPEN FILES

UNTIL WS-EOF=‘Y’

Page 51: COBOL History

51

What should you do?

• Ask questions• Read chapter• Do exercises at end

of chapter• Think!• Ask questions!