CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.

Slides:



Advertisements
Similar presentations
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Advertisements

CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
The IDENTIFICATION and ENVIRONMENT DIVISIONS Chapter 2.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
An Overview of Computers and Logic
An Overview of Programming Logic and Design
Guide To UNIX Using Linux Third Edition
Understanding the Mainline Logical Flow Through a Program (continued)
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Programming Logic and Design Fourth Edition, Introductory
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.
Programming Logic and Design Fifth Edition, Comprehensive
An Overview of Computers and Logic
Structured COBOL Programming, Stern & Stern, 9th edition
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)
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 Chapter 4. To familiarize you with methods used to 1. Access input and output files 2. Read data from an input file 3. Perform simple move operations.
CIS Computer Programming Logic
Chapter To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL.
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)
Chapter 1: Introduction to Computers and Programming.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.
The DATA DIVISION Chapter 3. COBOL Data Organization Field - group of characters forming a meaningful unit or basic fact –Characters in a name or digits.
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.
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
1 Interactive vs Batch Programs Cobol suited for developing both types of programs Interactive programs Accept input data from keyboard Input data processed.
CS CS Computing for Business Instructor:David Tucker GTA:Batul Mirza.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
1 The Procedure Division Chapter 4. 2 Main Two Sections File Section –Used to define files and record formats –Field names within records Working Storage.
Statement Syntax1 THE SELECT STATEMENT Purpose: designates a file and points to its physical location Syntax Definition : SELECT file-name-1 ASSIGN TO.
1 IDENTIFICATION and ENVIRONMENT DIVISIONS. 2 Objectives Basic Structure of COBOL Programs General Coding and Formatting Rules Identification and the.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Chapter 3 Decision Making. What is IF? The primary method of changing the flow of a program is by making decisions using the IF verb. The following example.
Structured Programming
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
Structured COBOL Programming, Stern & Stern, 9th Edition CHAPTER 2 Cobol Language Fundamentals.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
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)
Submitted To: Rutvi sarang Submitted By: Kushal Bhagat.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
IBM-Mainframes COBOL Class-1. Background and History  COBOL is an acronym for: Common Business Oriented Language  COBOL was developed in 1959 by the.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
371 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Engineering Problem Solving With C An Object Based Approach
Computer Programming.
Structured Programming
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Topics Introduction Hardware and Software How Computers Store Data
High Level Programming Languages
Using screens and adding two numbers - addda.cbl
Presentation transcript:

CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez

What is a Computer? Components of a Computer Input Unit(s); Keyboard, tape, disks Output Unit(s); CRT, tape, disks Memory (Storage) units [Addresses] Control Unit (Executes Instructions) Arithmetic/Logic Unit (Math and Logic) Only ‘understands’ machine language

Hardware / Software Hardware: Physical equipment Software: Programs, commands, etc. System: O/S, compilers, utilities, etc. Application: User or third party supplied. Languages: Assembler, Basic(VB), Fortran, RPG, Easytrieve, C, C++, C#, Ada, Java, … Compiler’s job - translate ‘source’ language to machine language (or ‘byte’ code)

Online vs Interactive Off-line = batch Local Batch Remote Batch Online = Interactive Many users with terminals (PC’s) Can be either local or remote Single/Multiple User - Timesharing

Data Organization Bit - Binary digIT - [on/off] or [1/0] Character - byte (8 Bits) Field - One or more Bytes (Characters) Record - One or more Fields File - One or more Records Database - One or more Files Usually contains ‘metadata’

Report Components Page Heading Column Headings Report Body Possibly with subtotals, etc. Summary Final totals, summary totals, etc.

Program Design Program Sequence of instructions describing actions to be taken by the computer Flowchart Graphical description of program logic Uses rectangles, diamonds, ovals, etc Pseudocode Symbolic representation of program logic More ENGLISH-like

Data Information Needed Type and Size Types Alphabetic (Seldom used = A) Alphanumeric (X) Numeric (Sign and Decimal)  Binary  Numeric  Packed Numeric  Floating Point, etc. (Compatibility)

Program Development Define problem Design test data Design program Code program Compile program Test program Document Program

Identifier Rules 30 Character Maximum A-Z, a-z, 0-9, ‘-’ Characters ‘-’ not first or last character Usually at least 1 alphabetic

‘CARD’ FORMAT Line Numbers (XNU) 07Comment / Debug Margin ‘A’ Margin ‘B’ Identification (XNU)

COBOL Divisions IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. Divisions can be divided into SECTIONS Sections can be divided into PARAGRAPHS Paragraphs are composed of SENTENCES

IDENTIFICATION IDENTIFICATION DIVISION. PROGRAM-ID. PROG1. All other entries are obsolete An ‘*’ in cc07 can be used (Comment)

ENVIRONMENT ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPUT-FILE ASSIGN TO MYINFILE. SELECT PRINT-FILE ASSIGN TO MYREPORT.

ENVIRONMENT (SELECTS) SELECT PRINT-FILE ASSIGN TO “\RMC\DATA\INPUT.DAT”. (For PC Files) SELECT PRINT-FILE ASSIGN TO PRINTER-QPRINT. (For AS400 Files)

DATA DATA DIVISION. FILE SECTION. FD INPUT-FILE. 01 INPUT-REC. 10 FILLER PIC X(80). FD PRINT-FILE. 01 PRINT-REC. 10 FILLER PIC X(132).

WORKING-STORAGE WORKING-STORAGE SECTION. Program’s ‘scratchpad’ LEVEL NUMBERS STARTS IN COLUMN COLUMN 12 AND UP  Usually use 05, 10, 15, 20,… EACH 01 IS A NEW RECORD All fields must be specified

PROCEDURE PROCEDURE DIVISION. 010-START-HERE. (INITIALIZATION) (PROCESS CONTROL LOOP) (TERMINATION)

OPEN OPEN INPUT file-name OPEN OUTPUT file-name (Gets files ready for processing)

ACCEPT ACCEPT identifier FROM DATE identifier will contain YYMMDD ACCEPT identifier FROM TIME identifier will contain HHMMSSMS (Used to get date and time) ACCEPT identifier [options] Gets data from keyboard

MOVE MOVE identifier-1 TO identifier-2 (Alpha - Left Just. - Space Filled) (Numeric - decimal aligned) (Edited - follows edit characters)

READ READ file-name [into WS-name] AT END ANY IMPERATIVE STATEMENT(S) END-READ READ INPUT-FILE INTO WS-IN-REC AT END MOVE “YES” TO EOF-FLAG END-READ

WRITE (Generic) WRITE record-name [FROM ws-name] AFTER ADVANCING identifier LINES END-WRITE WRITE PRINT-REC FROM WS-PRINT-REC AFTER ADVANCING WS-SPACING END-WRITE

WRITE (New-Page) MOVE SPACES TO PRINT-REC WRITE PRINT-REC AFTER ADVANCING PAGE END-WRITE (Used to start new page for heading.)

PERFORM PERFORM Paragraph-name UNTIL Condition PERFORM 100-READ-INPUT PERFORM 300-PROCESS-DATA UNTIL EOF-FLAG = “YES”

ADD ADD literal TO identifier-1 ADD 1 TO REC-COUNT ADD identifier-1 TO identifier-2 ADD WS-SPACING TO WS-LINES

Decisions - Simple IF Condition-1 True Statements END-IF

Relational Conditions > GREATER THAN < LESS THAN = EQUAL TO >= GREATER OR EQUAL <= LESS OR EQUAL NOT can be used with all of the above

Decisions - ELSE IF condition-1 True Statements ELSE False Statements END-IF

Decisions - Examples IF HOURS-WORKED > 40 PERFORM 350-CALC-OVERTIME ELSE PERFORM 360-CALC-REGTIME END-IF

Decisions - complex IF complex-condition True statements ELSE False statements END-IF

Complex - conditions Two or more simple conditions connected with ‘AND’ or ‘OR’. IF (DEPARTMENT = 234 AND HIRE-DATE < “ ”) ADD 1 TO OVER-5-YEARS END-IF

CLOSE CLOSE file-name CLOSE INPUT-FILE (Terminate file processing.)

GOBACK / STOP RUN GOBACK. (Returns to ‘calling’ entity.) STOP RUN. (Returns to Operating System)