Screen Section Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Check Digit - Mod 11 Please use speaker notes for additional information!
Advertisements

2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Final Total Lines in COBOL Please be sure you can see the speaker notes - they contain additional information!
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)
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
The IDENTIFICATION and ENVIRONMENT DIVISIONS Chapter 2.
Processing with VSAM Files Please use speaker notes for additional information!
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
1 10/25/06CS150 Introduction to Computer Science 1 Reading from and Writing to Files.
COBOL COmmon Business Oriented Language  Work began in 1959 and has never stopped.
COBOL for the 21st Century
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.
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.
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.
Chapter To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL.
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)
Modifications to program Addda.cbl Please use speaker notes for additional information!
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!
Introduction to Tables/Arrays Please use the speaker notes for additional information. Tables/Arrays.
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.
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.
Array - adding to array at run time Please see speaker notes for additional information!
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
Edit Programs Please use speaker notes for additional information. Example: payedit.cbl payedit.cbl.
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.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
Explanation of SAMPLEIF (if88in1.cbl or if88in1.html) Please use speaker notes for additional information!
HELLO WORLD program in COBOL - CIS12 Please use speaker notes for additional information!
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
COBOL Screens Please use speaker notes for additional information!
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.
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.
IBM-Mainframes COBOL Class-1. Background and History  COBOL is an acronym for: Common Business Oriented Language  COBOL was developed in 1959 by the.
Module 1 1. Cobol Hierarchy Revised on COBOL Hierarchy There are four DIVISIONS:- IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. DATA DIVISION.
Programming Assignment #2 in CIS12 Please use speaker notes for additional information!
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!
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.
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!
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.
Introduction to the Array
Chapter 3 The DATA DIVISION.
Please use speaker notes for additional information!
Structured COBOL Programming
Chapter 14 Sorting and Merging.
Indexed File Processing
CHAPTER 17 The Report Writer Module
Using screens and adding two numbers - addda.cbl
Presentation transcript:

Screen Section Please use speaker notes for additional information!

IDENTIFICATION DIVISION. PROGRAM-ID. SCR1FROM. AUTHOR. GROCER. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPUT-FILE ASSIGN TO "A:\SCR1.DAT". DATA DIVISION. FILE SECTION. FD INPUT-FILE DATA RECORD IS INPUT-REC. 01 INPUT-REC. 05 ID-IN PIC XXXX. 05 NAME-IN PIC X(20). WORKING-STORAGE SECTION. 01 INDICATORS. 05 EOF-IND PIC XXX VALUE "NO ". 01 RESPONSES. 05 RESPONSE-IN-WS PIC X VALUE SPACES. SCREEN SECTION. 01 DATA-ENTRY-SCREEN BACKGROUND-COLOR IS 3 FOREGROUND-COLOR IS 5 BLANK SCREEN. 05 VALUE "DATA ENTRY SCREEN" LINE 01 COL VALUE "ID #: " LINE 05 COL ID-ON-SCR-IN LINE 05 COL 15 PIC XXXX FROM ID-IN. 05 VALUE "NAME:" LINE 07 COL NAME-ON-SCR-IN LINE 07 COL 15 PIC X(20) FROM NAME-IN. 05 VALUE "C - TO CONTINUE" LINE 16 COL VALUE "Q - TO QUIT" LINE 17 COL VALUE "ENTER CHOICE:" LINE 19 COL RESPONSE-SCR LINE 19 COL 45 PIC X TO RESPONSE-IN-WS. SCR1AFRM.CBL The SCREEN SECTION allows the programmer to layout the entire look of the screen - usually the limit is 24 lines deep and a max of 80 characters across (usually 80 means scrolling.) Here I am setting the background and foreground colors for the screen and cleaning it out prior to displaying it. When you are just putting up a literal, you can use VALUE with the location. The name of the field where data will be displayed is not used in this program. The FROM clause tells where the data is coming from - in this case from the input record. Note that the PIC is the same size. Response is taken in TO and stored.

PROCEDURE DIVISION. MAINLINE. PERFORM A-100-INITIALIZE. PERFORM B-100-PROCESS. PERFORM C-100-TERMINATE. STOP RUN. A-100-INITIALIZE. OPEN INPUT INPUT-FILE. B-100-PROCESS. READ INPUT-FILE AT END MOVE "YES" TO EOF-IND. PERFORM B-200-LOOP UNTIL EOF-IND = "YES" OR RESPONSE-IN-WS = "Q". B-200-LOOP. DISPLAY DATA-ENTRY-SCREEN. ACCEPT DATA-ENTRY-SCREEN. READ INPUT-FILE AT END MOVE "YES" TO EOF-IND. C-100-TERMINATE. CLOSE INPUT-FILE. *Input file: *1111Linda L. Hall *1212Stephen Daniels *1234David T. Anderson *245Peter Lyons *1228Daniel Russel *2222Ann Costa *2525Russel Warren *2728Ann Daniels *3333William Souza *3456Larry Richards *4444Marilyn Smith *4567Dale Ponti *5517Mary Collins *6666Robert Fallon The ACCEPT takes in anything the user enters using the TO clause. The DISPLAY puts the contents of DATA-ENTRY- SCREEN on the screen including the things referred to by the FROM clause. SCR1AFRM.CBL

IDENTIFICATION DIVISION. PROGRAM-ID. SCR1FROM. AUTHOR. GROCER. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPUT-FILE ASSIGN TO "A:\SCR1.DAT". DATA DIVISION. FILE SECTION. FD INPUT-FILE DATA RECORD IS INPUT-REC. 01 INPUT-REC PIC X(24). WORKING-STORAGE SECTION. 01 INDICATORS. 05 EOF-IND PIC XXX VALUE "NO ". 01 RESPONSES. 05 RESPONSE-IN-WS PIC X VALUE SPACES. 01 DATA-FOR-SCREEN. 05 ID-IN-WS PIC XXXX VALUE SPACES. 05 NAME-IN-WS PIC X(20) VALUE SPACES. SCREEN SECTION. 01 DATA-SCREEN BACKGROUND-COLOR IS 3 BLANK SCREEN. 05 VALUE "DATA SCREEN" LINE 01 COL VALUE "ID #: " LINE 05 COL ID-ON-SCR-IN LINE 05 COL 15 PIC XXXX FROM ID-IN-WS. 05 VALUE "NAME:" LINE 07 COL NAME-ON-SCR-IN LINE 07 COL 15 PIC X(20) FROM NAME-IN-WS. 05 VALUE "C - TO CONTINUE" LINE 16 COL VALUE "Q - TO QUIT" LINE 17 COL VALUE "ENTER CHOICE:" LINE 19 COL RESPONSE-SCR LINE 19 COL 45 PIC X TO RESPONSE-IN-WS. SCR1FROM.CBL

PROCEDURE DIVISION. MAINLINE. PERFORM A-100-INITIALIZE. PERFORM B-100-PROCESS. PERFORM C-100-TERMINATE. STOP RUN. A-100-INITIALIZE. OPEN INPUT INPUT-FILE. B-100-PROCESS. READ INPUT-FILE INTO DATA-FOR-SCREEN AT END MOVE "YES" TO EOF-IND. PERFORM B-200-LOOP UNTIL EOF-IND = "YES" OR RESPONSE-IN-WS = "Q". B-200-LOOP. DISPLAY DATA-SCREEN. ACCEPT DATA-SCREEN. READ INPUT-FILE INTO DATA-FOR-SCREEN AT END MOVE "YES" TO EOF-IND. C-100-TERMINATE. CLOSE INPUT-FILE. SCR1FROM.CBL The READ…INTO takes the record that was read and puts a copy into DATA-FOR-SCREEN. FD INPUT-FILE DATA RECORD IS INPUT-REC. 01 INPUT-REC PIC X(24). WORKING-STORAGE SECTION. 01 INDICATORS. 05 EOF-IND PIC XXX VALUE "NO ". 01 RESPONSES. 05 RESPONSE-IN-WS PIC X VALUE SPACES. 01 DATA-FOR-SCREEN. 05 ID-IN-WS PIC XXXX VALUE SPACES. 05 NAME-IN-WS PIC X(20) VALUE SPACES. The DISPLAY puts the data on the screen and the ACCEPT takes user input.

SCR1FROM.CBL

IDENTIFICATION DIVISION. PROGRAM-ID. SCR1TO. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT OUTPUT-FILE ASSIGN TO "A:\SCR1TO.DAT". DATA DIVISION. FILE SECTION. FD OUTPUT-FILE DATA RECORD IS OUTPUT-REC. 01 OUTPUT-REC PIC X(24). WORKING-STORAGE SECTION. 01 RESPONSES. 05 RESPONSE-IN-WS PIC X VALUE SPACES. 01 DATA-FROM-SCREEN. 05 ID-IN-WS PIC XXXX VALUE SPACES. 05 NAME-IN-WS PIC X(20) VALUE SPACES. SCREEN SECTION. 01 DATA-ENTRY-SCREEN BACKGROUND-COLOR IS 7 FOREGROUND-COLOR IS 4 BLANK SCREEN. 05 VALUE "DATA ENTRY SCREEN" LINE 01 COL VALUE "ID #: " LINE 05 COL ID-ON-SCR-IN LINE 05 COL 15 PIC XXXX TO ID-IN-WS. 05 VALUE "NAME:" LINE 07 COL NAME-ON-SCR-IN LINE 07 COL 15 PIC X(20) TO NAME-IN-WS. 05 VALUE "C - TO CONTINUE" LINE 16 COL VALUE "Q - TO QUIT" LINE 17 COL VALUE "ENTER CHOICE:" LINE 19 COL RESPONSE-SCR LINE 19 COL 45 PIC X TO RESPONSE-IN-WS. SCR1TO.CBL

PROCEDURE DIVISION. MAINLINE. PERFORM A-100-INITIALIZE. PERFORM B-100-PROCESS. PERFORM C-100-TERMINATE. STOP RUN. A-100-INITIALIZE. OPEN OUTPUT OUTPUT-FILE. B-100-PROCESS. MOVE SPACES TO OUTPUT-REC. DISPLAY DATA-ENTRY-SCREEN. ACCEPT DATA-ENTRY-SCREEN. PERFORM B-200-LOOP UNTIL RESPONSE-IN-WS = "Q". B-200-LOOP. IF RESPONSE-IN-WS = "C" WRITE OUTPUT-REC FROM DATA-FROM-SCREEN. MOVE SPACES TO OUTPUT-REC. DISPLAY DATA-ENTRY-SCREEN. ACCEPT DATA-ENTRY-SCREEN. C-100-TERMINATE. CLOSE OUTPUT-FILE. The information stored in DATA-FROM- SCREEN is moved to OUTPUT-REC and written if the user responses to the screen with a C. The initializing display and accept takes in the information for the first record. From this point forward, the display and accept will be at the bottom of the loop.

SCR1TO.CBL

SCR2TO.CBL IDENTIFICATION DIVISION. PROGRAM-ID. SCR2TO. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT OUTPUT-FILE ASSIGN TO "A:\SCR2.DAT". DATA DIVISION. FILE SECTION. FD OUTPUT-FILE DATA RECORD IS OUTPUT-REC. 01 OUTPUT-REC PIC X(24). WORKING-STORAGE SECTION. 01 RESPONSES. 05 RESPONSE-IN-WS PIC X VALUE SPACES. 01 DATA-FROM-SCREEN. 05 ID-IN-WS PIC XXXX VALUE SPACES. 05 NAME-IN-WS PIC X(20) VALUE SPACES. SCREEN SECTION. 01 DATA-ENTRY-SCREEN. 05 ID-SECTION. 10 VALUE "DATA ENTRY SCREEN" BLANK SCREEN LINE 01 COL VALUE "ID #: " LINE 05 COL ID-ON-SCR-IN LINE 05 COL 15 PIC XXXX TO ID-IN-WS. 05 NAME-SECTION. 10 VALUE "NAME:" LINE 07 COL NAME-ON-SCR-IN LINE 07 COL 15 PIC X(20) TO NAME-IN-WS. 05 RESPONSE-SECTION. 10 VALUE "C - TO CONTINUE" LINE 16 COL VALUE "Q - TO QUIT" LINE 17 COL VALUE "ENTER CHOICE:" LINE 19 COL RESPONSE-SCR LINE 19 COL 45 PIC X TO RESPONSE-IN-WS.

SCR2TO.CBL PROCEDURE DIVISION. MAINLINE. PERFORM A-100-INITIALIZE. PERFORM B-100-PROCESS. PERFORM C-100-TERMINATE. STOP RUN. A-100-INITIALIZE. OPEN OUTPUT OUTPUT-FILE. B-100-PROCESS. MOVE SPACES TO OUTPUT-REC. DISPLAY ID-SECTION. ACCEPT ID-ON-SCR-IN DISPLAY NAME-SECTION. ACCEPT NAME-ON-SCR-IN. DISPLAY RESPONSE-SECTION. ACCEPT RESPONSE-SCR. PERFORM B-200-LOOP UNTIL RESPONSE-IN-WS = "Q". B-200-LOOP. IF RESPONSE-IN-WS = "C" WRITE OUTPUT-REC FROM DATA-FROM-SCREEN. MOVE SPACES TO OUTPUT-REC. DISPLAY ID-SECTION. ACCEPT ID-ON-SCR-IN. DISPLAY NAME-SECTION. ACCEPT NAME-ON-SCR-IN. DISPLAY RESPONSE-SECTION. ACCEPT RESPONSE-SCR. C-100-TERMINATE. CLOSE OUTPUT-FILE. This shows the use of the three sections. Each is displayed and accepted separately.

IDENTIFICATION DIVISION. PROGRAM-ID. SCR1USE. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT DATA-FILE ASSIGN TO "A:\SCR2.DAT". DATA DIVISION. FILE SECTION. FD DATA-FILE DATA RECORD IS DATA-REC. 01 DATA-REC PIC X(24). WORKING-STORAGE SECTION. 01 INDICATORS. 05 EOF-IND PIC XXX VALUE "NO ". 01 RESPONSES. 05 RESPONSE-IN-WS PIC X VALUE SPACES. 01 DATA-ON-SCREEN. 05 ID-IN-WS PIC XXXX VALUE SPACES. 05 NAME-IN-WS PIC X(20) VALUE SPACES. SCREEN SECTION. 01 DATA-ENTRY-SCREEN. 05 VALUE "DATA ENTRY SCREEN" BLANK SCREEN LINE 01 COL VALUE "ID #: " LINE 05 COL ID-ON-SCR-IN LINE 05 COL 15 PIC XXXX FROM ID-IN-WS. 05 VALUE "NAME:" LINE 07 COL NAME-ON-SCR-IN LINE 07 COL 15 PIC X(20) USING NAME-IN-WS. 05 VALUE "C - TO CONTINUE" LINE 15 COL VALUE "R - REWRITE RECORD" LINE 16 COL VALUE "Q - TO QUIT" LINE 17 COL VALUE "ENTER CHOICE:" LINE 19 COL RESPONSE-SCR LINE 19 COL 45 PIC X TO RESPONSE-IN-WS. SCR1USE.CBL The USING displays data and then lets the user change it.

SCR1USE.CBL PROCEDURE DIVISION. MAINLINE. PERFORM A-100-INITIALIZE. PERFORM B-100-PROCESS. PERFORM C-100-TERMINATE. STOP RUN. A-100-INITIALIZE. OPEN I-O DATA-FILE. B-100-PROCESS. READ DATA-FILE INTO DATA-ON-SCREEN AT END MOVE "YES" TO EOF-IND. PERFORM B-200-LOOP UNTIL EOF-IND = "YES" OR RESPONSE-IN-WS = "Q". B-200-LOOP. DISPLAY DATA-ENTRY-SCREEN. ACCEPT DATA-ENTRY-SCREEN. IF RESPONSE-IN-WS = "R" REWRITE DATA-REC FROM DATA-ON-SCREEN. READ DATA-FILE INTO DATA-ON-SCREEN AT END MOVE "YES" TO EOF-IND. C-100-TERMINATE. CLOSE DATA-FILE.