Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.

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)
7-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)
Data types and variables
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
Objectives You should be able to describe: Data Types
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)
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)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
1 © 2000 John Urrutia. All rights reserved. Qbasic Constructing Qbasic Programs.
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 Examples to Accompany Structure Topic Please use speaker notes for additional information!
Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.
CNG 140 C Programming Lecture Notes 2 Processing and Interactive Input Spring 2007.
A First Book of ANSI C Fourth Edition Chapter 3 Processing and Interactive Input.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
7-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
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.
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).
7-1 Chapter 7.  Basic Arithmetic Verbs  Options Available with Arithmetic Verbs  COMPUTE Statement  Signed Numbers in Arithmetic Operations  Intrinsic.
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.
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.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
Lecture 41 Arithmetic Clauses The ROUNDED clause –Place ROUNDED after the variable that holds the result ADD A TO B ROUNDED. ADD A TO B GIVING C ROUNDED.
Move and Edited Output1 NON-NUMERIC: Left justify the data in the memory location. If the length of the data is smaller than the length of the field (as.
INPUT / OUTPUT STATEMENTS
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
7-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 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.
Any Questions? Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect.
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.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
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.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
The Selection Structure
Designing and Debugging Batch and Interactive COBOL Programs
Any Questions?.
2.1 Parts of a C++ Program.
Chapter 3 The DATA DIVISION.
A First Book of ANSI C Fourth Edition
An Introduction to Structured Program Design in COBOL
Chapter 14 Sorting and Merging.
Iteration: Beyond the Basic PERFORM
Scope and System Time/Date
Agenda Collating sequence / Sorting data
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
Decision Making Using the IF and EVALUATE Statements
Presentation transcript:

lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed digit ValuePICStored 0Z(4)(spaces) 0ZZZ90 87ZZZ987 +2,319ZZ,ZZZ-2, ZZ,ZZZ ,933Z,ZZZ.99-5, Z,ZZZ

lecture 32 PROCEDURE DIVISION Contains instructions to read, process, and output data I/O operations (OPEN, CLOSE, READ, WRITE), MOVE, DISPLAY, ACCEPT, Arithmetic (ADD, SUBSTRACT, MULTIPLY, DIVIDE), STOP RUN, …

lecture 33 Coding the Procedure Division Divide into paragraphs Each paragraph represents one procedure The first procedure should represent the function of the entire program The procedures called by the first procedure should represent the functions performed by those procedures

lecture 34 PERFORM/PERFORM UNTIL PERFORM procedure-name. Skips to the named procedure, executes it, and returns to the statement after the PERFORM. PERFORM procedure-name UNTIL condition. Execute the procedure until the condition is true. It’s a loop statement The condition is tested first Execution continues after PERFORM when condition is true.

lecture 35 STOP RUN statement STOP RUN. Terminates the program Should appear only once in your program All files should be closed prior to executing this statement

lecture 36 MOVE - Assignment MOVE {data-name | literal } TO data-name-2 ….  Copies data from a sending field to one or more receiving fields MOVE NUMBER-ENTERED TO PAY-RATE. MOVE “Y” TO END-OF-SESSION-SWITCH. MOVE 1 TO PAGE-NUMBER.  Move data to multiple locations MOVE 15 TO NUM-1 NUM-2 NUM-3

lecture 37 MOVE The original data is retained in the sending field (only a copy operation) If the sending field is numeric and the receiving field is numeric edited, the MOVE converts from one form to the other If (receiving field size > sending field size) then –filled out with trailing blanks in an alphanumeric move, or –leading zeros in a numeric move If (receiving field size < sending field size) then moved data is truncated

lecture 38 SENDING FIELDRECEIVING FIELD Alphabetic Alphanumeric Numeric Numeric Edited ALPHABETIC ALPHANUMERIC NUMERIC NUMERIC EDITED Valid Invalid Valid Integer Valid Invalid Integer Valid Invalid Integer Valid Invalid MOVE Rules

lecture 39 Examples Alphanumeric  Alphanumeric PIC SendingContentsPIC Rec.Contents X(5)‘ABCDE’X(5)‘ABCDE’ X(5)‘ABCDE’X(4)‘ABCD’ X(5)‘ABCDE’X(6)‘ABCDE ‘ Data is copied from left to right with space filling or truncation on the right The contents of the receiving item are completely replaced

lecture 310 Examples Numeric  Numeric PIC SendingContentsPIC Rec.Contents 9(5)123459(5) (5)123459(4)2345 9(5)123459(6) (3)V99123^459(3)123 9(3)V99123^459V993^45 9(3)1239(3)V99123^00 Data is aligned at the decimal point with zero filling or truncation as necessary When the decimal point is not explicitly specified, an assumed decimal point is implied immediately after its rightmost character

lecture 311 OPEN  Read/Write  Close OPEN –Only the files you declared in a SELECT and corresponding FD statements CLOSE –You should close a file when either : it will not be read/written anymore before the program ends File I/O

lecture 312 OPEN and CLOSE OPENINPUT filename-1... OUTPUTfilename-2 … CLOSEfilename … INPUT is a file you read into the program OUTPUT is a file the program writes into OPEN/CLOSE many files on the same line Call OPEN before any READ/WRITE After CLOSE you cannot READ/WRITE. If you OPEN an input file again, you can read the records starting from the first record

lecture 313 READ READ filename AT END statement END-READ. The filename is defined with FD Reads a single record Each successive call reads the next record AT END (optional) executes the statement if the EOF has been reached END-READ is optional (don’t forget period).

lecture 314 Priming Read Pseudocode Read input record  Priming Read Loop if not EOF Calculate information Read input next record End-loop

lecture 315 Priming Read … MOVE ‘N’ TO INPUT-EOF. READ INPUT-FILE AT END MOVE ‘Y’ TO INPUT-EOF. … PERFORM PROCESS-RECORDS UNTIL INPUT-EOF = ‘Y’. … PROCESS RECORDS … READ INPUT-FILE AT-END MOVE ‘Y’ TO INPUT-EOF.

lecture 316 WRITE WRITE record-name AFTER/BEFORE ADVANCING more. more is PAGE integer [LINE | LINES] data-name [LINE | LINES] One record is written to the file AFTER/BEFORE ADVANCING (optional) –Printer usage to advance to the top of the next page or advance a number of lines

lecture 317 DISPLAY DISPLAY (data-name-1 | literal-1) … WITH NO ADVANCING. Display literals or data values on the screen A single DISPLAY can display several items (separated by spaces) and then a carriage return The WITH NO ADVANCING clause (optional) suppresses the carriage return Handy tool to debug your program

lecture 318 Examples DISPLAY “ “. DISPLAY DISPLAY “ ” DISPLAY “End of Session.”. DISPLAY SALES-AMOUNT. DISPLAY “THE SALES AMOUNT IS “ SALES-AMOUNT “.”.

lecture 319 ACCEPT ACCEPT data-name FROM reserve-word. Waits for input from the user Input is stored in the variable data-name and the cursor moves to the next line Input should be consistent with the PIC of the data-name. If not, it may be truncated or adjusted. FROM reserve word (optional) : DATEPIC 9(6)YYMMDD DAYPIC 9(5)YYDDD DAY-OF-WEEKPIC 91 = Monday TIMEPIC 9(8)HHMMSSss ss = S/100 military time

lecture 320 ADD DATA NAMEA BC Value before execution Value after execution of: ADD A TO C ADD A B TO C ADD A TO B GIVING C ADD A 18 B GIVING C ADD A 18 B TO C ADD 1 TO B C

lecture 321 DATA NAMEA BCD Value before execution Value after execution of: SUBTRACT A FROM C SUBTRACT A B FROM C SUBTRACT A B FROM C GIVING D SUBTRACT 10 FROM C D SUBTRACT

lecture 322 DATA NAMEA BC Value before execution Value after execution of: MULTIPLY B BY A GIVING C MULTIPLY A BY B GIVING C MULTIPLY A BY B MULTIPLY B BY A MULTIPLY A BY 3 GIVING B C MULTIPLY

lecture 323 DATA NAMEA BC Value before execution Value after execution of: DIVIDE 2 INTO B DIVIDE 2 INTO B GIVING C DIVIDE B BY 5 GIVING A DIVIDE A INTO B C DIVIDE A INTO B GIVING C DIVIDE 3 INTO A GIVING B REMAINDER C DIVIDE

lecture 324 Conditions Format : {variable|literal|reserve-const} symbol {variable|literal|reserve-const} Symbol = <>>=<= Reserve-const ZERO, ZEROS, SPACE, SPACES