To familiarize you with  Options of MOVE statement  Rules for moving fields and literals  Printing edit symbols  Designing and printing reports 1.

Slides:



Advertisements
Similar presentations
6-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)
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)
Introduction to C Programming
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)
Programming Logic and Design Fourth Edition, Introductory
Introduction to C Programming
Entering Data in Excel. Entering numbers, text, a date, or a time n 1Click the cell where you want to enter data. n 2Type the data and press ENTER or.
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.
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)
October 2003Bent Thomsen - FIT 3-21 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
1 Data List Spreadsheets or simple databases - a different use of Spreadsheets Bent Thomsen.
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.
1 ADVANCED MICROSOFT EXCEL Lesson 9 Applying Advanced Worksheets and Charts Options.
Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.
6-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Agenda Reporting Work on Assignment 4! Printing on power systems.
BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two.
7-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
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.
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
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
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)
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
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.
Arithmetic and Edited Pictures. Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal.
Lecture 61 Editted Output Editing Functions –Two broad classes : A) insertion and B) replacement and suppression 1.Printing decimal points 2.Suppressing.
INPUT / OUTPUT STATEMENTS
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.
Structured Programming
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)
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.
13-1 Sequential File Processing Chapter Chapter Contents Overview of Sequential File Processing Sequential File Updating - Creating a New Master.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Working with Data Lists.
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.
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
1 Excel Lesson 2 Organizing the Worksheet & Formulas Microsoft Office 2010 Introductory Pasewark & Pasewark.
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
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.
16- 1 Chapter 16.  To familiarize you with  COPY statement for copying parts of a program stored in a library  CALL statement for executing called.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
COMPUTER LITERACY NOTES MS-EXCEL. SPREADSHEETS A spreadsheet is a computer equivalent of a paper ledger sheet. Excel allows you to create spreadsheets.
MANAGING TEXT FLOW Lesson 5. OBJECTIVES SOFTWARE ORIENTATION The Page Layout tab contains groups of commands that will produce a formatted document’s.
6-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)
Structured Programming
Any Questions?.
INPUT & OUTPUT scanf & printf.
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Structured COBOL Programming
Iteration: Beyond the Basic PERFORM
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
CHAPTER 17 The Report Writer Module
Decision Making Using the IF and EVALUATE Statements
Presentation transcript:

To familiarize you with  Options of MOVE statement  Rules for moving fields and literals  Printing edit symbols  Designing and printing reports 1

 MOVE identifier-1 TO identifier-2  Copies contents of identifier-1 To identifier- 2  identifier-1 is sending field  identifier-2 is receiving field 2 FORMAT 1

 Move Qty-In To Qty-Out  Contents of Qty-Out replaced by contents of Qty-In  If Qty-In = 253, contents of Qty-Out = 253 after MOVE executed  Qty-In remains unchanged  Simple 3 Example

 MOVE literal-1 TO identifier-2  Value of literal-1 copied to identifier-2  Data type of literal and identifier should match ◦ Move numeric literals to numeric fields ◦ Move nonnumeric literals to alphanumeric fields 4 FORMAT 2

 05 Qty-Out Pic Color-Out Pic X(4). Move 100 To Qty-Out Move 'Blue' To Color-Out  Contents of Qty-Out replaced with 100  Contents of Color-Out replaced with 'Blue' 5 Examples

 MOVE identifier-1 TO identifier-2 … literal-1 Move 0 To Total-1, Total-2, Total-3  Move may have multiple receiving fields  Contents of all three total fields set to 0 6 Full Format

 ZEROS may be moved to numeric or alphanumeric field ◦ Moves 0 to every position of receiving field  SPACES moved only to alphanumeric field ◦ Moves space or blank to every position of receiving field  Nice initializing feature 7

 Numeric field or literal is moved to numeric receiving field  Decimal alignment always maintained ◦ If is moved to a field  86 always treated as integer part of number .52 always treated as decimal part of number  Digits in integer part moved right to left starting at decimal point  Digits in decimal part moved left to right starting at decimal point  Note that the decimal is more important 8

 Operation: Move Amt-1 To Amt-2 Amt-1 Amt-2 Picture 99V99Picture 99V99 Contents 12 ^ 34Contents 67 ^ 89  Digits in integer part moved so that ◦ 2 replaces 7, 1 replaces 6  Digits in decimal part moved so that ◦ 3 replaces 8, 4 replaces 9  Very intuitive 9

 If receiving field has more integer positions than sending field ◦ Unfilled high-order (leftmost) integer positions filled with zeros  If receiving field has more decimal positions than sending field ◦ Unfilled low-order (rightmost) decimal positions filled with zeros 10

 Operation: Move Amt-3 To Amt-4 Amt-3 Amt-4 Picture 9V9Picture 99V99 Contents 3 ^ 4Contents 56 ^ 78  Digits in integer part moved so that ◦ 3 replaces 6, 0 replaces 5  Digits in decimal part moved so that ◦ 4 replaces 7, 0 replaces 8 11

 Operation: Move Amt-3 To Amt-4 Amt-3 Amt-4 Picture 9V9Picture 99V99 Contents 3 ^ 4Contents 56 ^ 78  After MOVE, contents of Amt-4 = 03 ^ 40  Note that it takes care of the left over digits 12

 If receiving field has fewer integer positions than sending field ◦ High-order (leftmost) digits truncated  If receiving field has fewer decimal positions than sending field ◦ Low-order (rightmost) digits truncated  Mathematically not good, can produce the greatest error. 13

 Operation: Move Amt-5 To Amt-6 Amt-5 Amt-6 Picture 99V99Picture 9V9 Contents 12 ^ 34Contents 5 ^ 6  Digits in integer part moved so that 2 replaces 5, 1 not moved  Digits in decimal part moved so that 3 replaces 6, 4 not moved 14

 Operation: Move Amt-5 To Amt-6 Amt-5 Amt-6 Picture 99V99Picture 9V9 Contents 12 ^ 34Contents 5 ^ 6  After MOVE, contents of Amt-6 = 2 ^ 3 15

 Sending field is alphanumeric field or nonnumeric literal  Receiving field is alphanumeric field 16

 Characters moved from left to right  If receiving field longer, low-order (rightmost) positions replaced with spaces  If receiving field shorter, low-order characters in sending field truncated 17

 Operation: Move Code-1 To Code-2 Code-1 Code-2 Picture X(3) Picture X(6) Contents abc Contents mnopqr  Characters abc replace mno  Remaining three positions in Code-2 replaced with blanks  Smart enough to blank out the rest. 18

 Operation: Move Code-3 To Code-4 Code-3 Code-4 Picture X(5) Picture X(3) Contents vwxyz Contents efg  Characters vwx replace efg  y and z are not moved since all positions in Code-4 are filled 19

 When receiving field is group item, alphanumeric MOVE rules followed  If subfields are numeric, invalid data may be stored in subfields 20

 Operation: Move "ABCD" To WS-Code 01 WS-Code. 05 WS-Part-1 Pic XX. 05 WS-Part-2 Pic 99.  After MOVE, value of WS-Part-1 is AB, WS- Part-2 is CD  Causes error if WS-Part-2 then used in arithmetic operation 21

 Asked about in Class  If same name is used in 2 different Records  Use OF or IN  Example ADD AMT OF IN-REC TO TOTAL  Can use OF or IN referring to a group or record 22

 Avoid using sending field with different data type than receiving field  Move numeric fields, numeric literals or ZEROS to numeric fields  Move alphanumeric fields, nonnumeric literals, ZEROS or SPACES to alphanumeric fields 23

24

 Edit symbols used to make data fields more readable ◦ Display as $14.95  Use spacing between lines and page margins for readability  Space fields across page or screen  Heading and footing lines added to improve clarity of output 25

 Create a new Record for output only  Report-item - elementary item that contains edit symbols in its PIC clause  Editing occurs when elementary item moved to report-item  PIC clause of report-item determines editing performed 26

 Implied decimal points (V) do not print  Move field with V in Picture to report-item field with actual decimal point for printing or displaying 27

 Operation: Move In-Amt To Out-Amt Field Picture Contents Positions In-Amt 99V9912 ^ 344 Out-Amt  Actual decimal point ◦ Replaces implied one ◦ Uses a storage position 28

 Zeros in leftmost position of number usually suppressed ◦ Value of number not affected and 25 have same value ◦ Improves readability  Edit symbol Z in PIC clause suppresses leading zeros, replaces with blanks 29

 Use Z for each position where leading zero should be replaced by blank In-Qty Out-Qty Pic 999 Pic ZZZ 018b18 003bb bbb b denotes a blank (space) in the print out 30 Examples 100 has no leading zeros so zeros not suppressed

 To suppress only some leading zeros ◦ Use Z's and 9's in same report-item  Z's must precede 9's In-Qty Out-Qty Pic 999 Pic ZZ9 003bb3 000bb0 31 Examples

 Zeros to right of decimal point are significant so they are not suppressed In-Cost Out-Cost Pic 99V99 Pic ZZ ^ 08 b ^ 02 bb ^ 00 bb Examples

 $ and, often used in PICTURE clause with Z and decimal point  Comma suppressed if only zeros precede it  Holds the location of $ sign In-Cost Out-Cost Pic 9(4)V99 Pic $Z,ZZZ ^ 40$1, ^ 06$bbb ^ 04$bbbbb Examples

 Check protection symbol  Used in place of Z to replace leading zeros with * instead of space  Prevents blanks from being filled in with numbers to change amount of check ◦ $ could be changed to $3, ◦ $***51.06 not easily changed 34

WS-Chk-Amt Out-Chk-Amt Pic 9(4)V99 Pic $*,*** ^ 15 $2, ^ 08$*** ^ 06$***** Examples

 PIC clause with 9’s is unsigned field ◦ Value assumed to be positive  Use S with 9’s in PIC clause of sending field to define signed field ◦ Use PIC of S9(3) to store -425  Report-item field must include + or - editing symbol to print or display a sign 36

 Use - (minus) symbol to display minus sign if sending field is negative ◦ Displays - for negative values ◦ Displays blank (no sign) for positive or unsigned values  Use + (plus) symbol to display sign for both positive and negative values ◦ Displays - for negative values ◦ Displays + for positive or unsigned values 37

Assume a PICTURE of S9(3) for WS-Amt Out-Amt WS-AmtPICTURE Contents ZZZ -bb ZZZ-218b ZZ9+b $ZZZ+$b Examples

 For accounting applications replace - (minus) sign with ◦ DB to debit an account when negative ◦ CR to credit an account when negative  Always specified to right of report-item  Print only when value moved to report item is negative 39

Assume a PICTURE of S9(3) for WS-Amt Notice it only prints if value is negative Out-Amt WS-AmtPICTUREContents CR123CR DB123DB CR123bb DB123bb 40 Examples

 B (space or blank), 0 (zero) or / (slash) may be inserted in report-item PIC as separator  Used to edit either nonnumeric or numeric fields 41

Assume PIC 9(3) for WS-Amt PIC X(3) for WS-Name Report-Item Contents PICTURE Contents WS-Amt BB9 52bb8 WS-Amt , ,000 WS-NameRAY XBXBX RbAbY WS-NameJAN X/X/X J/A/N 42 Examples

 Editing performed when ◦ Sending field moved to report-item ◦ Result of arithmetic operations stored in report- item  PICTURE of report-item determines type of editing 43

 All items used in arithmetic operation must be numeric  Error if report-item used in calculation of result  This statement invalid if Total-Out is report- item Add WS-Total To Total-Out  Report-item may be used after GIVING 44

 Used to place $, + or - directly preceding first significant digit  For example, becomes $5.16 instead of $ 5.16  In edit string, replace all Z’s with floating character ($, + or -)  Suppresses leading zeros, commas 45

Assume a PICTURE of S9(4)V99 for WS-Amt Out-Amt WS-AmtPICTURE Contents 0002 ^ 29 - $$,$$$.99bbbb$ ^ ,+++.99bbb ^ bb Examples

 To print spaces when sending field is all zeros rather than $.00 or -0  For the report-item 05 Qty-Out Pic +++ Blank When Zero. 035 will print as will print as bbb (all spaces) 47

48

 Define each type of output line as separate 01-level record in WORKING-STORAGE  May include 01-level records for heading, detail, total, footing lines, etc.  Establishes separate storage area for each record  All constants and blanks may be preassigned with VALUE clauses 49

 To transfer data from storage to print area and then print  Replaces MOVE and WRITE Write Print-Rec From Heading-1 instead of Move Heading-1 to Print-Rec Write Print-Rec 50

01 HEADING-1 05HL-LITERAL-1PIC X(76) JUSTIFIED RIGHT. 05PIC X(76) VALUE SPACES. MOVE ‘MONTHLY TRANSACTIONS’ TO HL-LITERAL-1 It will be placed in positions

 Single spacing for WRITE is default  Use AFTER or BEFORE ADVANCING to obtain any number of blank lines between each print line 52

WRITE record-name-1 [FROM identifier-1] AFTER integer-1LINE BEFORE identifier-2LINES ◦ integer-1 or identifier-2 must be non-negative integer value ◦ AFTER ADVANCING prints line after paper is spaced ◦ BEFORE ADVANCING prints line before spacing occurs 53 FORMAT ADVANCING

 Write Print-Rec From Heading-Line-1 After Advancing 2 Lines ◦ Causes paper to advance two lines ◦ Heading-Line-1 printed on second line ◦ Creates double spacing - one blank line followed by printed line 54

 Write Print-Rec From Heading-Line-1 Before Advancing 2 Lines ◦ Heading-Line-1 printed first, then spaces two lines ◦ Results in overprinting if first line already contains printed output ◦ As a rule, use either BEFORE or AFTER in program consistantly but not both 55

 Word PAGE after ADVANCING causes paper to advance to next page  To advance paper to top of new page and print a heading, code Write Print-Rec From Heading-Line-1 After Advancing Page 56

 When page is full, need to advance to next page and print headings again  Define WORKING-STORAGE field for line counter  Initialize line counter to zero and increment it each time a line is printed  When line counter equals or exceeds line limit for page, advance to next page 57

 Define WORKING-STORAGE field for page number  Initialize and then increment page number each time new page begins  Move page number to report-item in heading line before printing it at top of a new page 58

 To get current date in program, access reserved word DATE  Stores date as six-digit field, two digits each for year, month and day  January 25, 2003 stored as

ACCEPT identifier-1 FROM DATE  For older compilers identifier must be defined as numeric field to hold 6 digits 60 FORMAT

Accept WS-Date From Date  Where WS-Date defined as: 01WS-Date. 05Run-YearPic Run-MonthPic Run-DayPic EXAMPLE

 WS-Date fields typically reformatted for printing  Moved to report-item fields listed in month, day, year order with slashes between them 62

 Newer compilers provide access to full four-digit year  Use intrinsic function CURRENT-DATE with MOVE in place of ACCEPT ◦ Change Run-Year in WS-Date to Pic 9(4) Move Function Current-Date To WS-Date ◦ If date is January 25, 2003 then 2003 will be stored in Run-Year 63

1. Include heading to identify report 2. Include date, page number 3. Include column headings to identify fields printed 4. Place most significant fields where they are most visible 5. Edit numeric fields for readability 64

6. Include totals at end of page or report 7. Use *’s to identify level of total Dept Total is $33,266.25* Final total is $167,267.53** 8. Include page footings at end of each page, report footings at end of report 65 EXAMPLE

 No COBOL standard for interactive processing  Two techniques used by compilers to add interactivity ◦ ACCEPT, DISPLAY enhancements with options to define appearance of data on screen ◦ SCREEN SECTION added in DATA DIVISON to define screen’s format 66

Display "Enter date of birth" At Line 13 Column 1 With Blank Screen Foreground-Color 1 Background-Color 7  Displays prompt at specific position on screen after clearing screen, using one color for characters and another for background 67 EXAMPLE

 Specify formats, options for screen  Follows WORKING-STORAGE  Define each screen with 01 level entry followed by subordinate entries  DISPLAY screen-name displays all prompts described in entries for screen  ACCEPT screen-name captures all data typed by user for that screen  There is much more than what is in these notes, like colors, reverse, sound, etc.  Page 227 has nice summary box. 68

01Screen-1. 05Blank Screen. 05Line 3 Column 1 Value 'City'. 05Column 17 Pic X(13) To City-In.  Display Screen-1 blanks screen and displays City in first column of line 3  Accept Screen-1 moves 13 characters user enters starting in line 3, column 17 to City-In  Let’s do a lab on this. 69 EXAMPLE

Will be able to use report-items in arithmetic operations Will be able to combine or concatenate nonnumeric literals in MOVE statement Move'Stu-Name Credits' & ' Tuition Scholarship' To Column-Heading-Line 70

Numeric MOVE Rules Decimal alignment maintained Integer and decimal portion digits moved from decimal point out Nonfilled high-, low-order positions replaced with zeros Truncation of high-, low-order digits occurs if receiving field not large enough 71

Nonnumeric MOVE Rules Movement from left to right Low-order nonfilled positions replaced with spaces Low-order characters truncated if receiving field not large enough 72

 Format of receiving field determines type of MOVE operation  See Table 6.3 in text for summary of edit symbols 73

 Rules for Printing Output ◦ Use Printer Spacing Chart to determine print positions to be used ◦ Define all printed output in WORKING-STORAGE so VALUE clause can be used ◦ Use appropriate editing symbols in report-items 74

 WRITE statement clauses ◦ Move records to print area in FILE SECTION with WRITE … FROM ◦ Use BEFORE or AFTER ADVANCING to control spacing between lines ◦ Use AFTER ADVANCING PAGE to go to beginning of next page 75

 Interactive Input/Output ◦ Use SCREEN SECTION or enhanced ACCEPT, DISPLAY verbs to make screen displays more user friendly ◦ Options available to  Describe exact line, column for item  Add color, sounds  Highlight, blink, underline, reverse video item  Clear all or part of screen 76