1-1 cobol for the 21 st century nancy stern hofstra university robert a. stern nassau community...

72
1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin- Stout (Emeritus) John Wiley & Sons, Inc. 11th edition

Upload: spencer-terry

Post on 23-Dec-2015

225 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-1

COBOL for the 21st Century

Nancy Stern Hofstra University

Robert A. Stern Nassau Community College

James P. Ley University of Wisconsin-Stout (Emeritus)

John Wiley & Sons, Inc.11th edition

Page 2: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-2

An Introduction to Structured Program Design in COBOL

Chapter 1

Page 3: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-3

Chapter Objectives

To familiarize you with

• Why COBOL is a popular business-oriented language.

• Programming practices and techniques• History of COBOL • Use of the current ANSI standard

versions of COBOL• Four divisions of a COBOL program

Page 4: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-4

Chapter Contents

• Computer Programming: An Overview• Applications Program Development

Process• Nature of COBOL• History of COBOL and the ANS

Versions

Page 5: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-5

Chapter Contents

• Techniques for Improving Program Design

• Sample Programs• Entering and Running a COBOL

Program on Your Computer

Page 6: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-6

Computer Program

• A set of instructions that enables computer to process data

• Also called software

• Two types of computer programs– Operating system programs - control

overall operations of computer– Applications programs - perform tasks

required by users

Page 7: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-7

Applications Programs

• Written by applications programmer• May provide quick solution to one-time

problem– Displaying average grade for set of exam

scores

• Or may be run on regularly scheduled basis– Program to print student transcripts each

semester

Page 8: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-8

Customized Application Programs

• Written for specific users like doctors, car dealerships

• Necessary if user has special requirements

Page 9: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-9

Applications Package

• Written for general user who needs program to perform standard tasks

• Standard tasks include budgeting, scheduling payroll, etc.

• Cheaper, easier than writing customized program

Page 10: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-10

Program Languages

Machine language• Only language computer understands• All programs executed on computer

must be in machine language• Machine language programs difficult to

write

Page 11: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-11

Program Languages

Symbolic language (like COBOL)• English-like languages used to write

programs• Easier than writing programs in machine

language• Must be translated or compiled into

machine language to run on computer

Page 12: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-12

Program Development Process

1. Determine Program Specifications

2. Design Program Using Program Planning Tools

3. Code and Enter Program

4. Compile Program

5. Test Program

6. Document Program

Page 13: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-13

1. Program Specifications

• Systems analysts, users and programmers develop specifications

• Specifications include:• Description of input and output data• Step-by-step processing required to

convert input to output

Page 14: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-14

1. Program Specifications

Record layout forms describe format of input and output data

• Data names of each data item in record

• Location of each data item in record

• Size of each data item

• Number of decimal positions (for numeric data items)

Page 15: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-15

1. Program Specifications

Printer spacing charts describe

• Spacing

• Layout of printed output

• Heading, detail, total lines

• Error messages

Page 16: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-16

2. Design the Program

Program planning tools used to map out structure and logic of program

• Flowcharts use block diagrams to represent logic

• Pseudocode uses English-like statements

• Hierarchy charts show relationships among sections of program

Page 17: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-17

3. Code and Enter Program

• Programmer writes and enters program into computer

• Program written in symbolic language (like COBOL)

• Called source program

Page 18: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-18

Source program in symbolic language

Object program in machine language

Translated by compiler

4. Compile Source Program

Compiler is program that

• Checks source program for rule violations

• Translates source program into object program

Page 19: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-19

5. Test Program

• Test or debug program to ensure it contains no errors

• Check for two types of errors– Compile-Time Errors– Execution Errors

Page 20: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-20

Compile-Time Errors

• Errors detected by compiler during translation from COBOL to machine language

• Detects violations of programming rules– Misspelled reserved words– Missing punctuation

• Also called syntax errors

Page 21: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-21

Execution Errors

• Detected when program is run

• Logic error causes incorrect output– Sequence of instructions incorrect– Wrong instruction coded

• Run-time error if computer cannot execute instruction– Attempt to divide by zero– Attempt to read a file that cannot be found

Page 22: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-22

Debugging Techniques

• Desk checking

• Correcting syntax errors

• Program walkthroughs

• Executing the program

Page 23: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-23

6. Document the Program

• Documentation - formal set of procedures and instructions to specify how to use program

• Written for– Those working with output– Computer operators who run program– Maintenance programmers who make

modifications to program

Page 24: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-24

Nature of COBOL

• Business-oriented language

• Standard language

• English-like language

• Relatively easy to understand

Page 25: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-25

History of COBOL

• Developed in 1959 as standard language to meet needs of business

• Committee to develop language convened by Department of Defense

• Included representatives from academia, business, computer manufacturers

Page 26: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-26

Standard Versions of COBOL• 1960s

• 1968

• 1974

• 1985

wide variations in COBOL compilers

first COBOL standard set by American National Standards Institute (ANSI)

second ANSI standard to make COBOL more efficient, standardized

this ANSI standard incorporated structured programming techniques

Page 27: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-27

Current and Future Standards

• 1985 currently the most widely used

• 2008 is next standard – Approval expected in 2008 or so– Information on 2008 COBOL standard at

http://www.ansi.org

Page 28: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-28

Future of COBOL

Likely to remain important language

• Older COBOL programs need to be updated

• Still used by many for new program development

Page 29: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-29

Use of COBOL

• About 200 billion lines of COBOL source code in use

• 5 billion new lines added each year

• Used by 42.7% of application programmers in medium to large U.S. companies

• $200 million in expected revenues for 2001

Page 30: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-30

Year 2000 Problem (Y2K)

• Year stored as two digits in older programs to save space

• 19 assumed as valid prefix for all years– 95 represented year 1995

• Invalid as prefix for years 2000 and beyond– 00 could mean 1900 or 2000

Page 31: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-31

Year 2000 Problem (Y2K)

Many calculations with dates incorrect starting in 2000

• To find your age if you were born in 1970

Subtract 70 from 95 (95 - 70 = 25)

• Calculation incorrect for year 2000 and beyond

00 - 70 = -70 when age should be 30

Page 32: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-32

Year 2000 Problem (Y2K)

To correct problem

• Billions of lines of code, many written in COBOL needed to be examined

• Code changed to use four digits for year

• Age, other calculations now correct1995 - 1970 = 25

2000 - 1970 = 30

Page 33: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-33

Year 2000 Problem (Y2K)

Page 34: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-34

Year 2000 Problem (Y2K)

Page 35: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-35

Improving Program Design

Two techniques used to develop programs that are easier to understand, test, debug and modify

• Structured Programming

• Top-Down Programming

Page 36: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-36

Structured Programming

• Eliminates use of GO TO statements – Allowed skipping to different sections of

program without returning to starting point

• Program logic easier to follow with "GO-TO-less" programming

Page 37: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-37

Structured Programming

Program divided into paragraphs

• Main paragraph or module controls logic flow using PERFORM statements

• Main module "performs" other modules when instructions in that module required

• Each module can be written and tested independently of others

Page 38: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-38

Top-Down Programming

• Another technique to make programs easier to understand, test, debug and modify

• Develop program like term paper– Develop outline first– Add details for each of main steps– Add further refinement for more complex

steps

Page 39: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-39

Top-Down Programming

For COBOL program

• Code main modules or routines first

• Code intermediate modules next

• Details deferred to minor modules and coded last

Page 40: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-40

Interactive vs Batch Programs

• Cobol suited for developing both types of programs

Interactive programs

• Accept input data from keyboard

• Input data processed immediately

• Output (results) displayed on screen immediately

Page 41: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-41

Interactive vs Batch Programs

Batch programs

• Process large volumes of input at periodic intervals

• Input data read in from files

• Output written to files

Page 42: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-42

Overview of the Four Divisions

• Every COBOL program contains up to four separate divisions in the following order:

IDENTIFICATION DIVISION

ENVIRONMENT DIVISION

DATA DIVISION

PROCEDURE DIVISION

Page 43: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-43

Overview of the Four Divisions

• IDENTIFICATION DIVISION– Identifies program to operating system– Provides documentation about program

• ENVIRONMENT DIVISION– Defines file-names– Describes devices used to store them– Not included in fully interactive programs

Page 44: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-44

Overview of the Four Divisions

• DATA DIVISION– Describes input and output format of data

in files– Defines any constants and work areas

• PROCEDURE DIVISION– Contains instructions to read input, process

it and create output

Page 45: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-45

Sample Interactive Program

• Purpose– to compute employee WAGES

• Input from keyboard– HOURS and RATE

• Processing– compute WAGES as HOURS x RATE

• Output displayed on screen– WAGES

Page 46: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-46

Sample Interactive Program

• IDENTIFICATION DIVISION– One required entry, PROGRAM-ID– Names the program

• DATA DIVISION– Describes and defines storage for all data – Data defined in WORKING-STORAGE

SECTION for interactive program

Page 47: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-47

Data Defined in Sample Program

• Keyed input fields (HOURS, RATE)• Output fields (WAGES)• Other fields used for processing

(MORE-DATA)

Page 48: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-48

PICTURE Clause

• 01 level begins definition of each field• PICTURE or PIC clause describes

– Type of data• Numeric (PIC 9)• Nonnumeric (PIC X)

– Size of field - determined by number of 9’s or X’s

Page 49: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-49

PICTURE Clauses

• RATE with PIC 99V99 includes V to show assumed decimal point position

• User enters data with decimal point– Program uses V to align data

• WAGES includes actual decimal point – Shown when value displayed on screen

Page 50: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-50

Giving Field Initial Value

• MORE-DATA with PIC XXX is nonnumeric field

• Assigned initial contents of YES by use of VALUE clause

• Value must be in quotation marks since MORE-DATA is nonnumeric field

Page 51: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-51

PROCEDURE DIVISION

• Set of instructions to be executed by program

• Organization of instructions planned before coding begins

• Pseudocode, an English-like description of program instructions, used for planning

• Describes program logic and order in which instructions will be executed

Page 52: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-52

PROCEDURE DIVISION

• PROCEDURE DIVISION includes one paragraph 100-MAIN

• List of instructions that follow make up paragraph

• Period follows last statement in paragraph (STOP RUN.)

• Main processing controlled by PERFORM … END-PERFORM loop

Page 53: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-53

PERFORM … END-PERFORM

• Repeats set of instructions as long as user enters YES in response to prompt

"IS THERE MORE DATA (YES/NO)?"

• MORE-DATA initially contains YES so instructions in loop executed first time

Page 54: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-54

PERFORM … END-PERFORM

• When user enters NO as response– MORE-DATA set to "NO" and loop ends

• After loop, STOP RUN is executed, ending program

Page 55: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-55

PERFORM … END-PERFORM

Statements in loop executed in order they are listed

• DISPLAY displays value in quotes or value of field on screen

• ACCEPT stores value user enters from keyboard in field

• MULTIPLY performs calculation to find WAGES

Page 56: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-56

Sample Batch Program

• In batch mode, data comes from input file instead of keyboard

• Data for each employee stored in a record in file on disk

• Employee name, hours and rate data called fields

Page 57: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-57

Sample Batch Program

• Calculated results (Wages) stored in file instead of displayed on screen

• For each input record– Record created and stored in output file– Includes employee name, hours, rate and

computed wages – File intended for printing so spacing added

between fields for readability

Page 58: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-58

COBOL Divisions

• All four divisions included for batch programs

• IDENTIFICATION DIVISION first with required PROGRAM-ID paragraph

• ENVIRONMENT DIVISION– INPUT-OUTPUT SECTION assigns input

and output files to specific devices

Page 59: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-59

DATA DIVISION

• FILE SECTION describes format of input and output files

• Fields in records described using PICTURE clause

• Decimal point not stored in input records– Use V for implied decimal for alignment

• Use actual decimal point for fields in output record so it is printed

Page 60: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-60

PROCEDURE DIVISION

• Contains instructions to be executed by computer

• Instructions executed in order they appear

• Includes two paragraphs with period at end of each

Page 61: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-61

100-MAIN-MODULE

• OPENs files to be used by program

• Repeatedly READs in records (PERFORM … END-PERFORM) until there are no more

• Calls second paragraph 200-WAGE-ROUTINE to process each record

• CLOSEs files after all records read

• Ends program (STOP RUN)

Page 62: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-62

READ Statement

• Reads one record into program storage area

• Record must be in storage to use it

• Takes one of two actions depending on whether record was read

Page 63: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-63

READ Statement

• PERFORM instruction after NOT AT END executed when record read– Statements in paragraph 200-WAGE-

ROUTINE executed to process record

• If no more records to be read, MOVE instruction after AT END executed– 'NO ' moved to ARE-THERE-MORE-

RECORDS, ends loop

Page 64: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-64

200-WAGE-ROUTINE

• First MOVE initializes PRINT-REC to blanks

• Then MOVEs name, hours, wages to output fields

• Calculates WAGES with MULTIPLY statement, MOVES it to output field

• WRITEs data in employee output record to print file

Page 65: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-65

Entering & Running a Program

To type in and run a COBOL program on your computer system, you need to know how to:

• Log on and off of the computer

• Name COBOL files on the computer

• Use a text editor to key in, modify and save files

• Compile a COBOL source program to translate it into machine language

• Link or load the object program

• Run the object program

Page 66: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-66

Chapter Summary

• The Nature of COBOL– English-like language – Used widely for business programming– With new standard coming out soon, it is

likely to remain important language

Page 67: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-67

Chapter Summary

• Use planning tools and good design techniques to improve program design

• Document programs well

• Carefully test and debug programs

Page 68: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-68

Chapter Summary

COBOL programs divided into four divisions

• IDENTIFICATION DIVISION identifies program to operating system

• ENVIRONMENT DIVISION required for batch programs that operate on files

Page 69: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-69

Chapter Summary

• DATA DIVISION defines formats for all input, output and work areas needed– FILE SECTION required for batch

programs that operate on files– WORKING-STORAGE SECTION for work

fields or fields used in interactive programs

Page 70: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-70

Chapter Summary

• PROCEDURE DIVISION– Contains instructions to process input and

produce output– Divided into paragraphs or modules

Page 71: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-71

Copyright © 2003 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976 United States Copyright Act without the express written permission of the copyright owner is unlawful. Request for further information should be addressed to the Permissions Department, John Wiley & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages, caused by the use of these programs or from the use of the information contained herein.

Page 72: 1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

1-72

An Introduction to Structured Program Design in COBOL

Chapter 1