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

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to XHTML Programming the World Wide Web Fourth edition.
Advertisements

1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 2 Getting Started.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
BASIC SKILLS AND TOOLS USING ACCESS
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
DT266/2 Information Systems COBOL Revision. Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment.
Intercompany Sales of Inventory
Managerial Accounting Second Edition Weygandt / Kieso / Kimmel
Structured COBOL Programming
Benchmark Series Microsoft Excel 2013 Level 2
Dilutive Securities and Earnings Per Share
 Copyright I/O International, 2013 Visit us at: A Feature Within from Item Class User Friendly Maintenance  Copyright.
Systems Analysis and Design with UML Version 2.0, Second Edition
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
Chapter 9 Interactive Multimedia Authoring with Flash Introduction to Programming 1.
PSSA Preparation.
Essential Cell Biology
Accounting Principles, Ninth Edition
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® PowerPoint 2010 © 2011 The McGraw-Hill Companies,
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 8Integrating Access Data.
Chapter 14 The User View of Operating Systems
Systems Analysis and Design
© Copyright 2011 John Wiley & Sons, Inc.
9-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)
8-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)
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
The Future of COBOL A Focus on Interactive Programming Appendix C Stern & Stern.
3-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emertius)
Chapter 5: Database Forms and Reports
7-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)
The IDENTIFICATION and ENVIRONMENT DIVISIONS Chapter 2.
5-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)
14-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)
COBOL for the 21st Century
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
15-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)
4-1 Coding Complete COBOL Programs: The PROCEDURE DIVISION Chapter 4.
4-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)
10-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)
4-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)
2-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 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
3-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emertius)
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
7-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
3-1 Chapter 3. To familiarize you with  Ways in which data is organized in COBOL  Rules for forming data-names  Defining input and output files in.
3-1 The DATA DIVISION Chapter Chapter Objectives To familiarize you with Systems design considerations Ways in which data is organized Rules for.
13-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)
9-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)
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
1 IDENTIFICATION and ENVIRONMENT DIVISIONS. 2 Objectives Basic Structure of COBOL Programs General Coding and Formatting Rules Identification and the.
Structured Programming
7-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)
Structured COBOL Programming, Stern & Stern, 9th Edition CHAPTER 2 Cobol Language Fundamentals.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
2-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)
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Slide 8-1 Chapter 8 Terms Programming Languages Introduction to Information Systems Judith C. Simon.
BUSINESS COMMUNICATION SECOND CANADIAN EDITION Part III: Writing for special purposes Chapter Nine: Writing business reports Original Slides by Gates Stoner.
371 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Structured Programming
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Structured COBOL Programming
Presentation transcript:

2-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

2-2 The IDENTIFICATION and ENVIRONMENT DIVISIONs Chapter 2

2-3 Chapter Objectives To familiarize you with Basic structure of a COBOL program General coding and format rules IDENTIFICATION and ENVIRONMENT DIVISION entries

2-4 Chapter Contents Basic Structure of a COBOL Program Coding Requirements of IDENTIFICATION DIVISION Sections of ENVIRONMENT DIVISION Assigning Files to Devices in ENVIRONMENT DIVISION

2-5 Humor

2-6 Basic COBOL Program Structure Originally, each COBOL instruction coded on single line of 80 characters Positions on line reserved for special purposes Rules may differ for your compiler Rigid column rules dropped in 2008

2-7 Coding Rules Columns 1-6 and optional and rarely used today Column 7 for continuation, comment, starting new page Columns 8-72 for COBOL program statements

2-8 Coding Rules Column 7 * (asterisk) designates entire line as comment / (slash) forces page break when printing source listing - (dash) to indicate continuation of nonnumeric literal

2-9 Margin Rules Columns 8-72 divided into two areas –Area A - columns 8, 9, 10, 11 –Area B - columns Division, section and paragraph-names must all begin in Area A –First letter of name must begin in column 8, 9, 10 or 11 –Entry may extend into Area B

2-10 Margin Rules All other statements, clauses, and sentences begin anywhere in Area B (column 12, 13, 14, etc.) –Select entries in ENVIRONMENT DIVISION –Data description entries in DATA DIVISION –All PROCEDURE DIVISION instructions

2-11 Review of Margin Rules Division and Section Names –Begin in Area A, end with a period –Must appear on a line with no other entries Paragraph-names –Begin in Area A, end with period followed by space –May appear on line by themselves or with other entries

2-12 Review of Margin Rules Statements and Sentences –Begin in Area B –May appear on line by themselves or with other entries –Statements (e.g., OPEN, WRITE) may end with period but not recommended –Sentences (e.g., a paragraph made up of one or more statements) end with period followed by space

2-13 IDENTIFICATION DIVISION Provides identifying information about program Divided into paragraphs PROGRAM-ID only required paragraph Other paragraphs optional

2-14 IDENTIFICATION DIVISION Format IDENTIFICATION DIVISION. PROGRAM-ID. program-name. [AUTHOR. [comment-entry] …] [other optional paragraphs]

2-15 Understanding Instruction Formats Instruction formats describe syntax of all parts of COBOL language Describe required and optional elements, ordering and punctuation All formats in text are correct although additional options may be available

2-16 Rules for Instruction Formats Uppercase words are COBOL reserved words Lowercase words are user-defined entries IDENTIFICATION DIVISION. PROGRAM-ID. program-name. –DIVISION is reserved word –program-name is user-defined data-name Example

2-17 Rules for Instruction Formats Underlined words are required Punctuation if specified is required IDENTIFICATION DIVISION. PROGRAM-ID. program-name. –IDENTIFICATION, DIVISION required –PROGRAM-ID is required paragraph –Periods required after division header, paragraph name and program-name Example

2-18 Rules for Instruction Formats Brackets [ ] mean item is optional, braces { } mean one of enclosed items required Ellipses (...) mean entry may be repeated IDENTIFICATION DIVISION. PROGRAM-ID. program-name. [AUTHOR. [comment-entry] …] –AUTHOR paragraph optional –If included it may have any number of comment entries Example

2-19 ENVIRONMENT DIVISION Describes files and computer devices used to process them Required by programs that process files This division is machine-dependent since devices differ from computer to computer Only division that may change if program run on different computer

2-20 Sections of Environment Division CONFIGURATION SECTION –Describes computer used to compile/execute program –Optional and recommended that you omit it INPUT-OUTPUT SECTION –Describes input and output files and devices used by program –Required for all programs using files

2-21 INPUT-OUTPUT SECTION Follows CONFIGURATION SECTION (if coded) Includes FILE-CONTROL paragraph –Contains one SELECT statement for each file used by program –Each SELECT defines a file-name and assigns device name to that file

2-22 INPUT-OUTPUT SECTION Format INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT file-name-1 ASSIGN TO implementor-name-1 [ORGANIZATION IS LINE SEQUENTIAL]. 1 1 Use this clause for all PC files so each line treated as separate record.

2-23 SELECT Statement file-names Choose meaningful file-names –EMPLOYEE-FILE instead of E-FILE –EMP-REPORT-FILE instead or OUT-FILE File-names are user-defined words –Words chosen by programmer to represent some element of program Must follow rules for forming user-define words

2-24 Rules for User-Defined Words 1.1 to 30 characters 2.Letters, digits, hyphens (-) only 3.No embedded blanks 4.At least one alphabetic character 5.May not begin or end with hyphen 6.May not be COBOL reserved word

2-25 SELECT implementor-names Conventions for these names vary widely among computers Most enable use of special device names for frequently used devices Printer SYSLST, SYS$OUT, PRINTER Disk DISC or DISK and disk file-name

2-26 SELECT implementor-names Special device-names example Select Transaction-File Assign to Disk "Data1". Select Report-File Assign to Printer. Some systems use name of file stored on disk (VAX or Alpha systems) Select Sales-File Assign to "Sales1".

2-27 SELECT Statements for PCs For PCs, use device names specifying –Drive on which file appears followed by a colon –Folder name if file is in a folder –Name of file PC example Select Inventory-File Assign To "C:\Inventory\Inv-File.dat".

2-28 ORGANIZATION clause for PCs This clause describes organization of records in the file Most PC disk files created as text files –Following data for each record, Enter key is pressed –Indicates end of the line and end of the record –If records 80 characters or less, each record appears on single line on screen or printer

2-29 ORGANIZATION clause for PCs Include LINE SEQUENTIAL to –Correctly read records from files when Enter key used to mark the end of each record –Create disk files with each record followed by Enter key so each record appears on separate line when printed

2-30 ORGANIZATION clause for PCs PC Example Select Sales-File Assign to "C:\Chapter2\Sales.dat" Organization is Line Sequential.

2-31 Coding Guidelines 1. Separate divisions by blank comment line, page eject symbol or blank line 2.Code a single statement per line 3.Code paragraph-names on line by themselves 4.Be liberal in use of comments. Box lengthy comments using asterisks.

2-32 Coding Guidelines 5. Code SELECT statements in logical order (input files first, then output files) although order not required 6. Use separate lines for SELECT, ASSIGN, ORGANIZATION clauses for readability 7.Avoid use of device-specific file- names

2-33 COBOL 2008 Changes Coding rules for Margins A and B will be recommended not required. PROGRAM-ID will be only paragraph in IDENTIFICATION DIVISION. All others can be specified as comments. Length of user-defined words will be increased from 30 to 60 characters.

2-34 Chapter Summary IDENTIFICATION DIVISION –Defines program name –Program name up to eight characters, letters and digits only, acceptable on all computers –PROGRAM-ID is only required paragraph, all others optional –Use comments by coding an * in column 7

2-35 Chapter Summary ENVIRONMENT DIVISION –Division is optional for COBOL 85 –Not needed for fully interactive programs –INPUT-OUTPUT SECTION required for any program using files –Only machine-dependent division since device specification, file-name rules vary among computers

2-36 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.

2-37 The IDENTIFICATION and ENVIRONMENT DIVISIONs Chapter 2