DT266/2 Information Systems COBOL Revision. Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 1.
Advertisements

Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
1.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 10 Arrays and Tile Mapping Starting Out with Games & Graphics.
Tables1 TABLES (chp. 12) group of storage locations (i.e. elements) with the same name accessed by name and subscript ex. var-name (sub) similar to arrays.
DT266/2 COBOL Basics – Declaring Data Basic Operations.
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
1 Displaying Open Purchase Orders (F/Y 11). 2  At the end of this course, you should be able to: –Run a Location specific report of all Open Purchase.
Lecture 7: Software Design (Part II)
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)
Chapter 11 Describing Process Specifications and Structured Decisions
Chapter 8 Improving the User Interface
Chapter 12 Array Processing and Table Handling. Defining Series of Input Fields Coding record with 24 independent hourly fields is cumbersome 01Temp-Rec.
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Files  File organisation and usage A record is a group of logically related fields A file is a group of logically related records Files are used to store.
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
VBA Modules, Functions, Variables, and Constants
Pseudocode.
Pseudocode.
Fundamentals of Python: From First Programs Through Data Structures
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)
12-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
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)
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.
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
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 Examples to Accompany Structure Topic Please use speaker notes for additional information!
COBOL Cobol is one of the most robust language in the software field, so far Cobol turned 50, in 2009 Cobol has stood the test of time Common Business.
Chapter 7 Array processing. Objectives To introduce arrays and the uses of arrays To develop pseudocode algorithms for common operations on arrays To.
Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.
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.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
14- 1 Chapter 14.  To familiarize you with ◦ How files may be sorted ◦ How to process file during SORT procedure  Before it is sorted  After it is.
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.
Indexed and Relative File Processing
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.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
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)
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
1 Review for test 2 Chapters 7, 8, 9, 11, What is wrong with the following paragraphs? PARA-A. PARA-B. ADD A TO B MOVE 0 TO X PERFROM PARA-A PERFORM.
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.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
Session 1 Module 1: Introduction to Data Integrity
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
This is It! It’s been a pleasure! Final Exam – format True / false 5 Multiple choice 5 Short answers10 Data manipulation10 SQL 3 Array’s12 File processing25.
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Structured Programming
Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler.
Programming in COBOL.
Designing and Debugging Batch and Interactive COBOL Programs
Any Questions?.
Chapter 3 The DATA DIVISION.
Structured COBOL Programming
Chapter 14 Sorting and Merging.
Iteration: Beyond the Basic PERFORM
Programming in COBOL-85 For IBM Mainframe System 390
Agenda Collating sequence / Sorting data
CHAPTER 17 The Report Writer Module
Boolean Expressions to Make Comparisons
Programming in COBOL.
Presentation transcript:

DT266/2 Information Systems COBOL Revision

Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment Division Configuration Section  Special-Names Input-Output Section  File-Control Data Division File Section Working-Storage Section Screen Section Report Section Linkage Section Procedure Division

Basic Statements Move Add Subtract Multiply Giving Divide Perform

Paragraphs Paragraph Grouping of statements that can be placed anywhere within a program Execute using PERFORM statement  PERFORM para-name. Use for maintainability and readability When a paragraph is executed, control returns to the statement after the perform Displaced paragraph Occurs after the stop run and performed from elsewhere in the program

Chapter 2 Hutty & Spence Data & Conditions Conditions, and, or, not, less than, ….. Data Pictures Computational and display data types PIC Types 9, A, X, Z, $, etc Decimals V,. Signs +. -, CR, DB Commas, currency MOVE Rules for different data types

Chapter 2 Hutty & Spence LEVELS Group Item 01 can contain subordinate items which must have higher number Level 88 Condition Name Specifies that a condition is true when value of data item changes to that defined in the associated picture clause 01 WS-MONTH. 88 VALID-MONTH VALUE 1 THROUGH FEBVALUE DAYVALUE 4,6,9,11. EVALUATE TRUE WHEN 30-DAY WHEN FEB WHEN OTHER END-EVALUATE

Validation Range Checks Level 88s Selection checks If Alphabetic checks Special names Complex checks Combine checks and, or, not Especially important when working with files No record should be written to a file unless the data is valid Reason for accepting into working-storage not directly into a file

Chapter 3, 4, 5, 6 Hutty & Spence Control Constructs - Selection IF statement IF …. THEN ELSE ENDIF EVALUATE statement EVALUATE WHEN A> B PERFORM A WHEN A<B PERFORM B WHEN OTHER PERFORM C END-EVALUATE

Chapter 3, 4, 5, 6 Hutty & Spence Control Constructs - Iteration PERFORM statement LEADING EDGE While Loop Test Before TRAILING EDGE Repeat Loop Test After VARYING For Loop

Chapter 3, 4, 5, 6 Hutty & Spence Control Constructs – Iteration LEADING EDGE Display “Enter Age : “. Perform Enter-Age until AGE-IN > 3 and AGE-IN < 19. Condition is evaluated at the start of each loop Execute 0 or more times TRAILING EDGE Perform Accept-Option WITH TEST AFTER UNTIL WS-OPTION >0 AND WS-OPTION < 6. Forces code to be executed at least once and then condition is tested

Chapter 3, 4, 5, 6 Hutty & Spence Control Constructs - Iteration FOR LOOP Perform Display-Array- Value varying WS- ARRAY-INDEX from 1 by 1 Execute statements a set number of times. FOR LOOP Perform Display-Array- Value varying WS- ARRAY-INDEX from 1 by 1 until ARRAY- INDEX > 10 Execute statements a set number of times.

Chapter 7 & 8 Hutty & Spence Arrays An array is a group item each of its elements belongs to it Each element has the same picture and the element ‘occurs’ a number of times Subscripting always starts at 1. Arrays are fixed length Indexing Can be part of the definition Can be controlled by another working storage variable

Chapter 7 & 8 Hutty & Spence 1- D Arrays Definition 01 months-of-the-year. 03 month-name pic AAA occurs 12 times indexed by month-no. Indexing Set month-no to 1. Set month-no up by 1. Referencing Display Month-Name (Month #)

Chapter 7 & 8 Hutty & Spence 2-D Arrays Definition 01 box-of-chocolates. 02 layer-of-chocolates occurs 4 times indexed by layer-no. 03 chocolate occurs 20 times pic 99 indexed by choc-no. Indexing as before Referencing Access lowest level Chocolate (layer #, chocolate #)

Chapter 7 & 8 Hutty & Spence Arrays - Initialising Within the procedure division Move Accept Use perform statement to control Within working storage section Redefines clause 01 Month-Days. 02 Jan-Dayspic 99value Feb-Dayspic 99value Mar-dayspic 99value Dec-dayspic 99value Days-arrayredefines Month-Days pic 99 occurs 12 times. OR 01 Days-of-yearpic 9(36) value Month-Daysredefines Days-of-year pic 99 occurs 12 times.

Chapter 11, 12, 13, 14 Hutty & Spence File Handling File Introduced in Environment Division Input-Output Section File-Control What happens ? Give logical name by which file will be referred to in program Give physical name and location of file Describe file organisation and method used to access it

Chapter 11, 12, 13, 14 Hutty & Spence File Handling Describe the structure of the records in the file Data Division File Section. FD 01 Each file must have a File Descriptor entry in the File Section Record must be level 01 Do not embed validation in file descriptors

Chapter 11, 12, 13, 14 Hutty & Spence File Organisation 3 Types Sequential  Records stored one after another in order in which they are written Indexed Sequential  Each record is given a key that determines its position Relative

Chapter 11, 12, 13, 14 Hutty & Spence File Access Sequential Access Next record in sequence is read/written A file whose organisation is sequential can only have sequential access Random Access Record is read/written by specifying its KEY Relative or Indexed Sequential Files Dynamic Access Combination of the above Relative or Indexed Sequential files

Chapter 11, 12, 13, 14 Hutty & Spence Sequential Files Writing Open output OR Open extend Write Close Reading Open Input Read Close Checking for End of File Read  AT END  NOT AR END End-Read Use a Level 88 Cannot Rewrite Can Delete

Chapter 11, 12, 13, 14 Hutty & Spence Indexed Sequential Files Declaring Organisation Keys (primary & alternate) Access method Reading Open Input OR Open I-O Read  Invalid Key  Not Invalid Key End-Read Close Positioning using a key START FILE-NAME KEY NOT < KEY-NAME INVALID KEY INVALID KEY CLAUSE {NOT INVALID KEY NOT INVALID KEY CLAUSE} END-START

Chapter 11, 12, 13, 14 Hutty & Spence Indexed Sequential Files Writing Open Output OR Open extend OR Open I-O Write  Invalid Key  Not Invalid Key End-write Close ReWriting Open I-O Rewrite  Invalid Key  Not Invalid Key End-Rewrite Close Must have positioned at record first Deleting Always ask DELETE record

Chapter 11, 12, 13, 14 Hutty & Spence Relative Files Records can be accessed directly, according to the number of the record within the file Each record has a key, which is it’s relative address from the start of the file This is suitable for only a small number of records

Chapter 17 Hutty & Spense Report Writer Report Section Reports written to external file Declare file to program File Definition FD Report is RD Report Definition  Must Define PAGE LIMIT No. of lines to print on each page HEADING Line at which heading will appear FIRST DETAIL Line at which first detail will appear LAST DETAIL Line at which last detail will appear FOOTING Line at which footing will appear

Chapter 17 Hutty & Spense Report Writer Each RD entry consists of one or more 01 level-number entries. Each 01 level-number entry identifies a report group A unit consisting of one or more print lines and is of a particular type. Report Heading - Printed once at start of the report Report Footing - Printed once at the end of the report Page Heading - Printed at the start of every page Page Footing - Printed at the end of every page Detail - Basic report detail, the body of the report Control Heading - Printed each time some particular value changes Control Footing - Printed each time some particular value changes

Chapter 17 Hutty & Spense Report Writer Defining Report Lines Must identify the type of line Have sub-ordinate items Must identify the line on which it is to be printed in the report For each section of the line must identify where the data to be included is positioned I.e. column Must identify the source of the data to be included on that line

Chapter 17 Hutty & Spense Report Writer Controlling Reports Define control in the report definition RD STOCK-REPORT CONTROLS ARE FINAL, DEPARTMENT Data to control report must appear in a detail or control line FINAL is a report writer specific word Ensures last control footing of the report will be output When detail line first generated report writer saves values of control data items Each time a detail line is generated report item checks to see if values have changed beginning with the first listed in the RD If a control data item changes it also cause all other control breaks that are sub-ordinate to it

Chapter 17 Hutty & Spense Report Writer Creating the report in Procedure Division OPEN File INITIATE the report GENERATE the lines of the report TERMINATE the report CLOSE File

Chapter 15 Hutty & Spence Sorting Simple Sorting File to be sorted is copied to special work file Records in this work file are sorted into the requested order Sorted work file is copied to an output file Declare Work-file in Environment Division Select SortFile assign to dummy. Define structure of workfile in File Section SD SORT-FILE. 01 S-CAR-RECORD. Sort file in Procedure Division SORT ON {ASCENDING/DESCENDING } KEY {IDENTIFIER} USING GIVING

Chapter 15 Hutty & Spence Sorting Selective Sorting Sort as before, but Cut down on the fields in the output file Or include other fields in the output file Change the procedure division to sort using an input procedure and output procedure instead of input and output files Define 2 more sections, one for the input procedure and one for the output procedure Release records into the sort and Return them from the sort Keywords USING and GIVING not required instead have INPUT PROCEDURE IS OUTPUT PROCEDURE IS

Chapter 15 Hutty & Spence Sorting Write record to sort file Read record from sort file