Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.

Slides:



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

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)
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.
Processing with VSAM Files Please use speaker notes for additional information!
General Algorithms for Common Business Problems
Chapter 8 Printing 1. In COBOL you send data to the printer by writing data to a file. In COBOL, the printer is defined as a file, and it is opened, closed,
Any Questions!. Agenda Fun with Functions –how to get the system date Condition Names INDARA and SI Iteration Logical Files Positioning the file pointer.
VSAM KSDS and COBOL Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access Method Services.
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)
Chapter 15 Relative Files.  File organization that converts key field to actual disk address to find location of record No need to look up disk address.
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.
10- 1 Chapter 10. To familiarize you with  Main types of computer-generated reports  Techniques used for efficient printing of group reports and control.
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)
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 13 Sequential File Processing. Master Files Set of files used to store companies data in areas like payroll, inventory Usually processed by batch.
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.
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.
Agenda Reporting Work on Assignment 4! Printing on power systems.
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.
Indexed Files continued. Figure 17.1 Sequential Update OLD MASTER TRANSACTION NEW MASTER ERROR MESSAGES UPDATE PROGRAM.
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.
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)
Sequential Files Chapter 13. Master Files Set of files used to store companies data in areas like payroll, inventory Set of files used to store companies.
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.
Any Questions? Control Breaks Agenda Control Breaks –Also known as Reports with sub-totals.
General Algorithms for Common Business Problems Simple Program Design Third Edition A Step-by-Step Approach 10.
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.
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
Pascal Programming Today Chapter 11 1 Chapter 11.
Any Questions? Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect.
13-1 Sequential File Processing Chapter Chapter Contents Overview of Sequential File Processing Sequential File Updating - Creating a New Master.
Lesson 2: Designing a Database and Creating Tables.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
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.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Lecture 21 ENVIRONMENT DIVISION  defines files external to the program and devices.  contains two sections: 1.CONFIGURATION SECTION.  identifies computers.
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
Control Break Processing
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 11: Sequential File Merging, Matching, and Updating Programming Logic and Design, Third Edition Comprehensive.
Any Questions!. Agenda Fun with Functions Externally Described Files Condition Names Iteration Logical Files Random Reads.
VSAM ESDS and RRDS Department of Computer Science Northern Illinois University September 2005 Some of the illustrations are from VSAM: Access Method Services.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
Random update Please use speaker notes for additional information!
Sequential Processing to Update a File Please use speaker notes for additional information!
RPG Programming with Printer Files
RPG Programming with Printer Files
Any Questions?.
Chapter 3 The DATA DIVISION.
Agenda Test next Week! SI or no SI? File Update Techniques – Review.
Programming Logic and Design Fourth Edition, Comprehensive
Structured COBOL Programming
CHAPTER 17 The Report Writer Module
Please use speaker notes for additional information!
Presentation transcript:

Printing on power systems

Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File

Printing Reports with COBOL

A Good Report… Heading (a meaningful report name) –Date and Page Number Column Headings (to identify data) Order column from left to right to highlight significant data Edit numbers for readability Include Totals at end of report and groups of items ** To identify the ‘level’ of a total Clearly indicate the end of the report.

Record Formats Each Record format is defined using it’s own Group-Item in the Working Storage Section. Record format name is defined using the 01 level Fields and literals are defined using subsequent levels with Picture & Values Clauses

How Many Record Formats? HeadingCustomer Accounts Date: Page: 999 Column Heading Date Amount Customer Heading Customer: 1015 Cindy Laurin Detail Line $ Detail Line $ Detail Line $ Customer Total* Totals: 1015 Cindy Laurin $ Customer Heading Customer: 1016 Bruce Nugent Detail Line $ Customer Total * Totals: 1016 Bruce Nugent$ Report Total ** Totals: All Customers $ End of Report *** End of Report

Picture Clause Review Define Variables Define how Variables are displayed

Editing Functions FunctionCharacter Printing of a / as a separator/ Printing of Decimal Point in an integer. Suppress Leading Zeros in an integerZ Print a Dollar Sign in front of an integer$ Print a Comma in an integer, Printing of + or – signs+ or - Printing of ‘Debit’ or ‘Credit’ symbolsDB or CR Printing of Spaces as separatorsB Printing of Zeros as separators0 Print Leading asterix*

Examples Trans-Amount PIC S9(6)V999 Value Report-ItemEdited Results PIC $ZZZ,ZZZ.99- PIC $ZZZ,ZZZ.99CR PIC $ZZZZZZB99 PIC $ZZZZZZ.99+

Examples Trans-Amount PIC S9(6)V999 Value Report-ItemEdited Results PIC 9(6)V999 PIC $999999V999 PIC $ZZZ,ZZZ.99 PIC $ZZZ,ZZZ.9

Examples Trans-Amount PIC S9(6)V999 Value Report-ItemEdited Results PIC $ZZZ,ZZZ.99- PIC $ZZZ,ZZZ.99CR PIC $ZZZZZZB99 PIC $ZZZZZZ.99+

Printing in COBOL FILE SECTION FD Customer-Report. 01 Print-Record-Out. WORKING STORAGE. 01 Heading-1 05 PIC X(8) Value Spaces. 05 PIC X(17) Value ‘Customer Accounts’ 05 PIC X(5) Value Spaces. 05 PIC X(6) Value ‘Date: ‘ 05 WS-Date-Out format of date. 05 PIC X(1) Value Spaces. 05 PIC X(6) Value ‘Page: ‘. 05 WS-Page PIC 9(3).

Printing or Writing to a Spooled File And using an IMPLIED MOVE WORKING-STORAGE. 01 Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’ 01 Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’ WRITE Print-Record-Out FROM Detail-Line-1 WRITE Print-Record-Out FROM Detail-Line-2

Printing or Writing to a Spooled File (using AFTER ADVANCING) Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1 AFTER ADVANCING 1 LINE. WRITE Print-Record-Out FROM Detail-Line-2 AFTER ADVANCING 1 LINE.

Printing or Writing to a Spooled File (using BEFORE ADVANCING) Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1 BEFORE ADVANCING 1 LINE. WRITE Print-Record-Out FROM Detail-Line-2 BEFORE ADVANCING 1 LINE.

Printing or Writing to a Spooled File (using AFTER ADVANCING) Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1. WRITE Print-Record-Out FROM Detail-Line-2 AFTER ADVANCING PAGE.

Printing or Writing to a Spooled File With MIXED advancing! Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1 AFTER ADVANCING 1 LINE. WRITE Print-Record-Out FROM Detail-Line-2 BEFORE ADVANCING 1 LINE.

Control Breaks A.K.A Level Breaks

Report Types Transaction Reports Summary or Group Reports Exception Reports

Summary or Group Reports Most efficiently handled using: – Logical Files to sort the data in Summary or Group order –Control Breaks methodology to process the data.

Control Break Occurs when there is a change in key fields when reading sequentially through a file

Customer Accounts Date: 05/04/00Page: 999 Date Amount Customer: 1015 Cindy Laurin-Moogk 05/01/00$ /02/00$ /03/00$ * Totals: 1015 Cindy Laurin-Moogk$ Customer: 1016 Bruce Nugent 05/01/00$ * Totals: 1016 Bruce Nugent$ ** Totals: All Customers $ *** End of Report Where’s the Control Break?

What do you do at a Control Break? Print the totals for the save or previous key Initialize the accumulators used for the group or level Print headings for the new or file key

Single Control Break (using ifs) Read the First Record (check for EOF) If not EOF Write the heading for file-key Move file-key to save-key Do While not End of File If save-key  file-key Calculate & Write totals for save-key Initialize Accumulators Move file-key to save-key Write headings for file-key Process Record Read the next Record (check for EOF) ENDDO Calculate & Write totals for save-key

Single Control Break (Using Nested Loops) Read the First Record (check for EOF) Do While not End of File Write the heading for file-key Move file-key to save-key Do While file-key = save-key and not EOF Process Record Read the next record (check for EOF) ENDDO Calculate & Write totals for save-key Initialize Accumulators ENDDO

Multiple Control Breaks (Using Ifs) Read the First Record (check for EOF) If not EOF Write the headings for file-key Move file-key to save-key Do While not End of File If save-Primary-key  file-Primary-key Calculate & Write totals for save-Secondary-key Calculate & Write totals for save-Primary-key Initialize Primary & Secondary Accumulators Move file-key to save-key Write headings for Primary & Secondary file-keys If save-Secondary-key  file-Secondary-key Calculate & Write totals for save-Secondary-key Initialize Secondary Accumulators Move file-Secondary-key to save-Secondary-key Write headings for file-Secondary-key Process Record Read the next Record (check for EOF) ENDDO Calculate & Write totals for save-Secondary-key Calculate & Write totals for save-Primary-key

Multiple Control Breaks (Using Nested Loops) Read the First Record (check for EOF) Do While not End of File Write the headings for file-Primary-key Move file-Primary-key to save-Primary-key Do While not EOF and file-Primary-key = save-Primary-key Write headings for file-Secondary-key Move file-Secondary-key to save-Secondary-key Do While not EOF and file-Secondary-key = save-Secondary-key and file-Primary-key = save-Primary-key Process Record Read the next record (check for EOF) ENDDO Calculate & Write totals for save-Secondary-key Initialize Secondary Accumulators ENDDO Calculate & Write totals for save-Primary-key Initialize Primary Accumulators ENDDO

28 Sequential Access Reads one record at a time Reads records in arrival / sorted sequence.

29 Defining Sequential organization with sequential Access SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is SEQUENTIAL ACCESS MODE is SEQUENTIAL. If the ORGANIZATION clause is omitted then it is assumed sequential.

30 Sequential Read. READ file-name AT END Perform end-of-file-logic NOT AT END Perform detail-processing END-READ

31 Random Access Techniques

32 Random Access Records are processed in some other order than the one in which they were physically written to the disk or indexed. A key field is looked up in an index, the address is retrieved and the record is accessed from the physical file using the address.

33 Dynamic Access Defined when a file will be used both randomly and sequentially

34 Normalization Theory (Relational Database Design) First Normal Form: –Information entities are divided into Files or Tables on the basis of their Relationships. Second Normal Form: –All Entities must have a logical dependency on the Primary Key (or part of). Third Normal Form: –All Entities must have a functional dependency on the Primary Key in it’s entirety.

35 Due to Normalization Practices, we usually have more than one file in our databases. Typically reports usually consists of one or more Sequential files and one or more Random Access files.

36 Defining INDEXED organization with Sequential Access SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is SEQUENTIAL RECORD KEY is EXTERNALLY-DESCRIBED-KEY File status is WS-STATUS. 03 WS-STATUS PIC XX.

37 FILE STATUS CLAUSE When this clause is used the system will provide feed back to a program in a on any I/O activity to a file. The STATUS variable can be tested for specific errors encountered. i.e. WRITE DATA-FILE INVALID KEY PERFORM CHECK-STATUS END-WRITE IF STATUS-FIELD = ‘00’ PERFORM ALL-IS-NORMAL END-IF.

38 Defining a Random Access File SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is RANDOM RECORD KEY is EXTERNALLY-DESCRIBED-KEY (with duplicates) File status is variable-name. STRICTLY RANDOM

39 Defining a Dynamic Access File SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is DYNAMIC RECORD KEY is EXTERNALLY-DESCRIBED-KEY (with duplicates) file status is variable-name.

40 Beware of File Status Code 95! Need to add ‘WITH DUPLICATES’ to your select statement or your need to take it out!

41 Randomly Retrieve a Record using a Random Defined File Update/Populate the Key Fields in the File. READ file-name INVALID KEY Perform invalid-logic NOT INVALID KEY Perform valid-logic END-READ.

42 Sequentially Read using a Random Defined Record Make sure that ACCESS is DYNAMIC!! READ file-name NEXT RECORD AT END Perform perform end-of-file-logic END-READ.

43 Positioning the File Pointer in an INDEXED organized file Used with ACCESS Sequential or dynamic access defined files. Initialize the record key START file-name INVALID KEY Perform Invalid-Logic NOT INVALID KEY Perform valid-logic END-START. A “start” MUST be followed by a valid read to retrieve the file data into the specific file’s area.

44 Other Random Access Verbs

45 REWRITE Updates a record in a file File must be opened as I-O instead of input Record must be read first before rewrite REWRITE record-name (FROM variable-name) INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-REWRITE.

46 DELETE Deletes a record from a file File must be opened as I-O The record must be read first DELETE file-name RECORD INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-DELETE.

47 WRITE Writes records to a file File must be opened as I-O or OUTPUT WRITE record-name (FROM variable) INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-WRITE.

48 Check the source for CPCH13B to familiarize and see an example. Source to be found in BAC344LIB CPCH13C for use of DECLARATIVES Used to declare / define / catch execution time situations / conditions “GLOBAL” to a program