Lecture 21 ENVIRONMENT DIVISION  defines files external to the program and devices.  contains two sections: 1.CONFIGURATION SECTION.  identifies computers.

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

Methodology for Program Development Tuition billing program –Specs –File descriptions –Report layout –Processing requirement $200/cr $25 union dues if.
Chapter 4 The Identification, Environment, and Data Divisions.
Figure 3.4The Building Blocks of Structured Programming A B (a) Sequence BA CONDITION? (b) Selection : ENTRYEXIT A B N (d) Case CONDITION? A (c) Iteration.
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)
The IDENTIFICATION and ENVIRONMENT DIVISIONS Chapter 2.
Modules, Hierarchy Charts, and Documentation
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
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.
COBOL Basics 1. COBOL coding rules  Almost all COBOL compilers treat a line of COBOL code as if it contained two distinct areas. These are known as;
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.
Chapter To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL.
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
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)
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
Chapter 5 Using Data and COBOL Operators. Initializing Variables When you define a variable in WORKING- STORAGE, you also can assign it an initial value.
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
Agenda Reporting Work on Assignment 4! Printing on power systems.
1 Chapter 14 - Sorting System Concepts –Sort key Major Key (Primary) Minor Key (Secondary) –Sort sequence Ascending - Low to high Descending – High 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.
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.
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.
COBOL Basics 2. H E N N E S S Y R M L M F Group Items/Records StudentDetails WORKING-STORAGE SECTION. 01StudentDetailsPIC X(26).
Module 2 Defining Data Revised Defining Data All definitions of data for COBOL takes place in the DATA DIVISION. All data defined are visible to.
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 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Statement Syntax1 THE SELECT STATEMENT Purpose: designates a file and points to its physical location Syntax Definition : SELECT file-name-1 ASSIGN TO.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
1 The Data Division. 2 Main Two Sections File Section –Used to define files and record formats –Field names within records Working Storage Section –All.
1 IDENTIFICATION and ENVIRONMENT DIVISIONS. 2 Objectives Basic Structure of COBOL Programs General Coding and Formatting Rules Identification and the.
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.
Any Questions? Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect.
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.
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
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.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Introduction to Sequential Files. COBOL's forte  COBOL is generally used in situations where the volume of data to be processed is large.  These systems.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Submitting Instructions on web site CS 1024 students Read guide
Structured Programming
Programming in COBOL.
Designing and Debugging Batch and Interactive COBOL Programs
Any Questions?.
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Structured COBOL Programming
Chapter 14 Sorting and Merging.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
CHAPTER 17 The Report Writer Module
Introduction to C Programming
Programming in COBOL.
Presentation transcript:

lecture 21 ENVIRONMENT DIVISION  defines files external to the program and devices.  contains two sections: 1.CONFIGURATION SECTION.  identifies computers for compiling and executing the program SOURCE-COMPUTER. system-name.  the computer that will be used for compiling the program OBJECT-COMPUTER. system-name.  the computer that will be used for executing or running the program 2. INPUT-OUTPUT SECTION.  associates files in a COBOL program with files known to the OS

lecture 22 INPUT-OUTPUT SECTION  supplies information concerning the input and output devices used in the program [INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT file-name ASSIGN TO implementor-name.]  FILE-CONTROL paragraph  SELECT statements start in Area B followed by a period.  file-name = name used in program.  implementor-name = device on which file resides (i.e., file path and name on disk in our case)  varies from compiler to compiler

lecture 23 DATA DIVISION  Data items that appear in the program DATA DIVISION. [FILE SECTION. [FD file-description-entry record-description-entry ] [WORKING STORAGE SECTION. [ record-description-entry...]]

lecture 24 DATA DIVISION  FILE SECTION  Define an FD for every file  I.e., for every SELECT statement in the ENVIRONMENT DIVISION.  File type (input or output file information)  The “physical characteristics” of these files must be defined exactly  WORKING-STORAGE SECTION (note the hyphen)  Reserves memory for non-I/O fields, e.g. variables and constants  Defines output lines (Printing reports, results, etc.)

lecture 25  FD (File Description) statement FD file-name [BLOCK CONTAINS integer-1 RECORDS] [RECORD CONTAINS integer-2 CHARACTERS]  BLOCK CONTAINS (block description) statement (optional)  RECORD CONTAINS (record description) statement (optional) FILE SECTION

lecture 26  BLOCK CONTAINS  Specify blocking factor (# records per disk sector)  Higher the factor fewer physical operations  Too low-level for us. OS does it for us.  Optional.  RECORD CONTAINS  Indicates the number of characters in a record  The compiler verifies the sum of individual data item sizes against the declared value  Optional. FILE SECTION

lecture 27 RECORD DESCRIPTION FD is followed by an associated record description :  Size and type of each field within a record  Order in which the fields appear  Relationship of the fields to one another Done through a combination of:  PICTURE CLAUSES  LEVEL NUMBERS

lecture 28 Picture Clauses  Describe the type and size of a field  Only three data types: Alphanumeric (PIC X) Numeric (PIC 9) Alphabetic (PIC A)  Format size is indicated by the number of times 9, X, or A appear  XXXX is the same as X(4)  Can use PICTURE IS, PICTURE, PIC IS, PIC  S denotes sign and appears at the beginning of PIC  Assumed decimal point –Use of a V, PIC 9V99 can hold 1.23

lecture 29 INCOMING RECORDDATA DIVISION RECORD DESCRIPTION VALUES v v v 9 87|65 4|3 | INCOMING-DATA-RECORD. 05 STUDENT-NAME PIC 9V STUDENT-NAMEPIC 99V9. 05 STUDENT-NAMEPIC STUDENT-NAMEPIC V Assumed Decimal Point

lecture 210 VALUE Clause  Initialize contents of a field with literals.  Literals  Numeric : VALUE 3.00  Non-numeric : VALUE ‘ENGINEERING’  Figurative constants : VALUE SPACES  SPACE or SPACES, ZERO or ZEROS, QUOTE or QUOTES, ALL literal

lecture 211 Level numbers LEVEL Numbers express DATA hierarchy Describe the relationship between the fields in the record Order in which the fields appear matter Valid levels numbers between 01 to level is the record-name; highest level of data (Starts in Area A) Items : (Start in Area B) –Group - can be further divided, cannot have PIC claus –Elementary - cannot be further divided, must have PIC clause Levels with the same number are independent items Lower levels of data have higher level #’s Indentation is not required, but good for readability Group item names end with a period

lecture 212 STUDENT-EXAM-RECORD STUDENT-NAMEEXAM-SCORESSS-NUM LAST NAME FIRST NAME INIT MATHENGLISH ALGGEOREADVOCLIT ALPHANUMERICNUMERIC Student Exam Record

lecture STUDENT-EXAM-RECORD. 05 STUDENT-NAME. 10 LAST-NAMEPICTURE IS X(15). 10 FIRST-NAMEPICTURE IS X(15). 10 MID-INITIALPICTURE IS X. 05 SOC-SEC-NUMPICTURE IS 9(9). 05 EXAM-SCORES. 10 MATH. 15 ALGEBRAPICTURE IS 9(5). 15 GEOMETRYPICTURE IS 9(5). 10 ENGLISH. 15 READINGPICTURE IS 9(5). 15 VOCABULARYPICTURE IS 9(5). 15 LITERATUREPICTURE IS 9(5). 01 STUDENT-EXAM-RECORD. 04 STUDENT-NAME. 08 LAST-NAMEPIC X(15). 08 FIRST-NAMEPIC X(15). 08 MID-INITIALPIC X. 04 SOC-SEC-NUMPIC 9(9). 04 EXAM-SCORES. 08 MATH. 12 ALGEBRAPIC GEOMETRYPIC ENGLISH. 12 READINGPIC VOCABULARYPIC LITERATUREPIC (a) Initial Coding (b) Alternative Specification Level Numbers and PICTURE Clauses

lecture 214 WORKING-STORAGE SECTION  Defines data names not referenced in the FILE SECTION.  Stores results of calculations, flags, switch control, constants  Used to define print lines (headings and details)  Intermediate data storage  FILLER (reserved word)  Defines a field not referenced elsewhere in the program  Typically holds spaces or constants  The word can be omitted (is optional)  Can be used to denote format of a print line WORKING-STORAGE SECTION. 01 HEADING LINE. 05 FILLER PIC X(10) VALUE SPACES. 05 PIC X(12) VALUE ‘STUDENT NAME’. 05 PIC X(110) VALUE SPACES.

lecture 215 COUNTERS and ACCUMULATORS  Counters and accumulators compute totals and/or averages.  Defined in the DATA DIVISION and given initial values: 01 COUNTERS-AND-ACCUMULATORS. 05 EMPLOYEE-COUNT PIC 999 VALUE ZERO. 05 TOTAL-PAY-AMOUNT PIC 9(6)V99 VALUE ZERO.  COBOL has reserved words that you cannot use for variable names.  You cannot use the word "COUNT" as a variable name, so use something descriptive like "EMPLOYEE-COUNT".

lecture 216 (b) COBOL Entries FD STUDENT-FILE RECORD CONTAINS 27 CHARACTERS. 01 STUDENT-RECORD. 05 STU-NAME. 10 STU-LAST-NAME PIC X(15). 10 STU-INITIALS PIC XX. 05 STU-CREDITSPIC 9(2). 05 STU-UNION-MEMBER PIC X. 05 STU-SCHOLARSHIP PIC 9(4). 05 STU-GPAPIC 9V99. STUDENT NAME LAST GPA INITIALS CREDITSUNION MEMBER SCHOLARSHIP (a) Program Specifications Development of a COBOL Program (File Section)

lecture 217 (b) COBOL Entries WORKING-STORAGE SECTION. 01 CONSTANTS-AND-RATES. 05 PRICE-PER-CREDIT PIC 9(3) VALUE UNION-FEEPIC 9(2) VALUE ACTIVITY-FEES. 10 1ST-ACTIVITY-FEEPIC 99 VALUE ST-CREDIT-LIMITPIC 99 VALUE ND-ACTIVITY-FEEPIC 99 VALUE ND-CREDIT-LIMITPIC 99 VALUE RD-ACTIVITY-FEEPIC 99 VALUE MINIMUM-SCHOLARHSIP-GPA PIC 9V9 VALUE 2.5. (a) Excerpt from the Program Specifications 1. Calculate tuition due at the rate of $200 per credit. 2. The union fee is $ Compute the activity fee based on the number of credits taken; $25 for 6 credits or less, $50 for 7 to 12 credits, and $75 for more than 12 credits. 4. Award a scholarship equal to the amount in the incoming record if, and only if, the GPA is greater than 2.5. Development of a COBOL Program (Constants and Rates)

lecture 218 (a) Report Layout Development of a COBOL Program (Print Lines)

lecture 219 (b) COBOL Entries 01 HEADING-LINE. 05 FILLERPIC X VALUE SPACES. 05 FILLERPIC X(12) VALUE ‘STUDENT NAME’. 05 FILLERPIC X(10) VALUE SPACES. 05 FILLERPIC X(7) VALUE ‘CREDITS’. 05 FILLERPIC X(2) VALUE SPACES. 05 FILLERPIC X(7) VALUE ‘TUITION’. 05 FILLERPIC X(2)VALUE SPACES. 05 FILLERPIC X(9)VALUE ‘UNION FEE’. 05 FILLERPIC X(2)VALUE SPACES. 05 FILLERPIC X(7)VALUE ‘ACT FEE’. 05 FILLERPIC X(2)VALUE SPACES. 05 FILLERPIC X(11)VALUE ‘SCHOLARSHIP’. 05 FILLERPIC X(2)VALUE SPACES. 05 FILLERPIC X(10)VALUE ‘TOTAL BILL’. 05 FILLERPIC X(48)VALUE SPACES. 01 DETAIL-LINE. 05 FILLERPIC X VALUE SPACES. 05 DET-LAST-NAMEPIC X(15). 05 FILLERPIC X(2) VALUE SPACES. 05 DET-INITIALSPIC X(2). 05 FILLERPIC X(5) VALUE SPACES. 05 DET-CREDITSPIC 9(2). 05 FILLERPIC X(2)VALUE SPACES. 05 DET-TUITIONPIC 9(6). 05 FILLERPIC X(7)VALUE SPACES. 05 DET-UNION-FEEPIC 9(3). 05 FILLERPIC X(8)VALUE SPACES. 05 DET-SCHOLARSHIPPIC 9(5). 05 FILLERPIC X(6)VALUE SPACES. 05 DET-IND-BILLPIC 9(6). 05 FILLERPIC X(49)VALUE SPACES. Development of a COBOL Program (Print Lines)