Relative Files..

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

Cobol application using ODBC or File processing Vandana Janeja CIS 365 With COBOL OR PowerCobol.
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.
BY: JOSHUA THOMAS IGNATIUS TOWERS COBOL. Overview What is COBOL History Design Implementations What did it do Program structure Data types Syntax Sample.
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
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!
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
Two and three dimension tables Please use speaker notes for additional information!
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.
Relative Files.. Creating a Relative File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateRelativeFromSeq. * Creates a Relative file.
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.
Introduction to COBOL. COBOL  COBOL is an acronym which stands for Common Business Oriented Language.  The name indicates the target area of COBOL applications.
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!
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.
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
Totals on the Screen Please use speaker notes for additional information!
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.
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.
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.
Explanation of SAMPLEIF (if88in1.cbl or if88in1.html) Please use speaker notes for additional information!
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
COBOL Screens Please use speaker notes for additional information!
Application Program Design Day3. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Objectives Basic CICS programming –Structure.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
READING AND WRITING FILES. READING AND WRITING FILES SEQUENTIALLY  Two ways to read and write files  Sequentially and RA (Random Access  Sequential.
Pascal Programming Today Chapter 11 1 Chapter 11.
Any Questions!. Agenda Fun with Functions –how to get the system date –How to get the next service date INDARA and SI Condition Names Iteration Logical.
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.
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
Indexed Files.. Creating an Indexed File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateIndexedFromSeq. * Creates an indexed file.
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
Any Questions!. Agenda Fun with Functions Externally Described Files Condition Names Iteration Logical Files Random Reads.
The PERFORM. The PERFORM Verb  Iteration is an important programming construct. We use iteration when we need to repeat the same instructions over and.
VSAM ESDS and RRDS Department of Computer Science Northern Illinois University September 2005 Some of the illustrations are from VSAM: Access Method Services.
Random update Please use speaker notes for additional information!
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.
General Introduction Algorithms. Let’s write a program  A program is a collection of statements written in a language the computer understands.  A computer.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to Computer Systems
Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler.
Basic operations in Matlab
Keyboard Input and Screen Display ––––––––––– Interactive Programming
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 7 Files and Exceptions
Any Questions?.
Chapter 3 The DATA DIVISION.
Agenda Test next Week! SI or no SI? File Update Techniques – Review.
An Introduction to Structured Program Design in COBOL
Chapter 14 Sorting and Merging.
Programming in COBOL-85 For IBM Mainframe System 390
Indexed File Processing
Please use speaker notes for additional information!
Using screens and adding two numbers - addda.cbl
Date Conversion Program
Language Translation Issues
Chapter 8 - Visual Basic Schneider
Any Questions?.
Language Translation Issues
Presentation transcript:

Relative Files.

Creating a Relative File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateRelativeFromSeq. * Creates a Relative file from a sequential file. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT SupplierFile ASSIGN TO "SUPP.DAT" ORGANIZATION IS RELATIVE ACCESS MODE IS RANDOM RELATIVE KEY IS SupplierKey FILE STATUS IS SupplierStatus. SELECT SupplierFileSeq ASSIGN TO "INSUPP.DAT". DATA DIVISION. FILE SECTION. FD SupplierFile. 01 SupplierRecord. 02 SupplierCode PIC 99. 02 SupplierName PIC X(20). 02 SupplierAddress PIC X(60). FD SupplierFileSeq. 01 SupplierRecordSeq. 88 EndOfFile VALUE HIGH-VALUES. 02 SupplierCodeSeq PIC 99. 02 SupplierNameSeq PIC X(20). 02 SupplierAddressSeq PIC X(60). WORKING-STORAGE SECTION. 01 SupplierStatus PIC X(2). 01 SupplierKey PIC 99.

Creating a Relative File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateRelativeFromSeq. * Creates a Relative file from a sequential file. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT SupplierFile ASSIGN TO "SUPP.DAT" ORGANIZATION IS RELATIVE ACCESS MODE IS RANDOM RELATIVE KEY IS SupplierKey FILE STATUS IS SupplierStatus. SELECT SupplierFileSeq ASSIGN TO "INSUPP.DAT". DATA DIVISION. FILE SECTION. FD SupplierFile. 01 SupplierRecord. 02 SupplierCode PIC 99. 02 SupplierName PIC X(20). 02 SupplierAddress PIC X(60). FD SupplierFileSeq. 01 SupplierRecordSeq. 88 EndOfFile VALUE HIGH-VALUES. 02 SupplierCodeSeq PIC 99. 02 SupplierNameSeq PIC X(20). 02 SupplierAddressSeq PIC X(60). WORKING-STORAGE SECTION. 01 SupplierStatus PIC X(2). 01 SupplierKey PIC 99.

Creating a Relative File PROCEDURE DIVISION. Begin. OPEN OUTPUT SupplierFile. OPEN INPUT SupplierFileSeq. READ SupplierFileSeq AT END SET EndOfFile TO TRUE END-READ PERFORM UNTIL EndOfFile MOVE SupplierCodeSeq TO SupplierKey MOVE SupplierRecordSeq TO SupplierRecord WRITE SupplierRecord INVALID KEY DISPLAY "SUPP STATUS :-", SupplierStatus END-WRITE END-PERFORM. CLOSE SupplierFile, SupplierFileSeq. STOP RUN.

Reading a Relative File. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. ReadRelative. * Reads a Relative file directly or in sequence ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT SupplierFile ASSIGN TO "SUPP.DAT" ORGANIZATION IS RELATIVE ACCESS MODE IS DYNAMIC RELATIVE KEY IS SupplierKey FILE STATUS IS SupplierStatus. DATA DIVISION. FILE SECTION. FD SupplierFile. 01 SupplierRecord. 88 EndOfFile VALUE HIGH-VALUES. 02 SupplierCode PIC 99. 02 SupplierName PIC X(20). 02 SupplierAddress PIC X(60). WORKING-STORAGE SECTION. 01 SupplierStatus PIC X(2). 88 RecordFound VALUE "00". 01 SupplierKey PIC 99. 01 PrnSupplierRecord. 02 PrnSupplierCode PIC BB99. 02 PrnSupplierName PIC BBX(20). 02 PrnSupplierAddress PIC BBX(50). 01 ReadType PIC 9. 88 DirectRead VALUE 1. 88 SequentialRead VALUE 2.

Reading a Relative File. PROCEDURE DIVISION. BEGIN. OPEN INPUT SupplierFile. DISPLAY "Enter Read type (Direct=1, Seq=2)-> " WITH NO ADVANCING. ACCEPT ReadType. IF DirectRead DISPLAY "Enter supplier key (2 digits)-> " WITH NO ADVANCING ACCEPT SupplierKey READ SupplierFile INVALID KEY DISPLAY "SUPP STATUS :-", SupplierStatus END-READ PERFORM DisplayRecord END-IF IF SequentialRead READ SupplierFile NEXT RECORD AT END SET EndOfFile TO TRUE PERFORM UNTIL EndOfFile END-PERFORM CLOSE SupplierFile. STOP RUN. DisplayRecord. IF RecordFound MOVE SupplierCode TO PrnSupplierCode MOVE SupplierName TO PrnSupplierName MOVE SupplierAddress TO PrnSupplierAddress DISPLAY PrnSupplierRecord END-IF.

Reading a Relative File. RUN OF REL-EG2.EXE USING SEQUENTIAL READING Enter Read type (Direct=1, Seq=2)-> 2 01 VESTRON VIDEOS OVER THE SEA SOMEWHERE IN LONDON 02 EMI STUDIOS HOLLYWOOD, CALIFORNIA, USA 03 BBC WILDLIFE BUSH HOUSE, LONDON, ENGLAND 04 CBS STUDIOS HOLLYWOOD, CALIFORNIA, USA 05 YACHTING MONTHLY TREE HOUSE, LONDON, ENGLAND 06 VIRGIN VIDEOS IS THIS ONE ALSO LOCATED IN ENGLAND 07 CIC VIDEOS NEW YORK PLAZZA, NEW YORK, USA RUN OF REL-EG2.EXE USING DIRECT READ Enter Read type (Direct=1, Seq=2)-> 1 Enter supplier key (2 digits)-> 05

Select and Assign for Relative Files

FDs for Relative Files

Relative File Verbs - OPEN

Relative File Verbs - READ

Relative File Verbs - Write and Rewrite

Relative File Verbs - DELETE

Relative File Verbs - START

Error Handling Using Declaratives. PROCEDURE DIVISION. DECLARATIVES. SectionOne SECTION. USE clause for this section. ParOne1. ???????????????? ParOne2. SectionTwo SECTION. ParTwo1. ParTwo2. END-DECLARATIVES. Main SECTION. Begin.

Error Handling Using Declaratives. PROCEDURE DIVISION. DECLARATIVES. FileError SECTION. USE AFTER ERROR PROCEDURE ON RelativeFile. CheckFileStatus. EVALUATE TRUE WHEN RecordDoesNotExist DISPLAY "Record does not exist" WHEN RecordAlreadyExists DISPLAY "Record already exists" WHEN FileNotOpen OPEN I-O RelativeFile END-EVALUATE. END-DECLARATIVES. Main SECTION. Begin.