Any Questions?.

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

DT266/2 COBOL Basics – Declaring Data Basic Operations.
8-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)
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 2: Introduction to C++.
Structured COBOL Programming, Stern & Stern, 9th Edition
12-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
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)
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
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.
Agenda Reporting Work on Assignment 4! Printing on power systems.
1 Chapter 14 - Sorting System Concepts –Sort key Major Key (Primary) Minor Key (Secondary) –Sort sequence Ascending - Low to high Descending – High to.
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
CS CS Computing for Business Instructor:David Tucker GTA:Batul Mirza.
Module 2 Defining Data Revised Defining Data All definitions of data for COBOL takes place in the DATA DIVISION. All data defined are visible to.
Lesson NUMERIC-FIELDPIC 9(5). 05 ALPHANUMERIC-FIELDPIC X(5).... IF NUMERIC-FIELD = 10...(valid entry) IF NUMERIC-FIELD = ‘10’... (invalid entry)
1 Chapter – 12 Table Lookups Table Codes –Expanded Values –Types of Codes Numeric Alphabetic Alphanumeric.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Edit Programs Please use speaker notes for additional information. Example: payedit.cbl payedit.cbl.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
More Syntax in COBOL  Moving Data  Selection Statements  System Date  Indicators in Display files.
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.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
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.
Chapter 8 – Data Validation
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.
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
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.
Any Questions! 2 Agenda Moving data Arithmetic Verbs Compute statement.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
LOGICAL CONTROL STRUCTURES (chp. 8)
Submitting Instructions on web site CS 1024 students Read guide
Using the Console.
Chapter 2: Introduction to C++
Visual Basic 6 (VB6) Data Types, And Operators
Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler.
ICS103 Programming in C Lecture 3: Introduction to C (2)
The Selection Structure
Programming in COBOL.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Any Questions?.
INPUT & OUTPUT scanf & printf.
2.1 Parts of a C++ Program.
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Chapter 14 Sorting and Merging.
Programming in COBOL-85 For IBM Mainframe System 390
Agenda Collating sequence / Sorting data
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
CS150 Introduction to Computer Science 1
CHAPTER 17 The Report Writer Module
Chapter 2: Introduction to C++.
Using screens and adding two numbers - addda.cbl
Date Conversion Program
Decision Making Using the IF and EVALUATE Statements
Programming in COBOL.
Presentation transcript:

Any Questions?

Agenda Moving Data Selection Statements System Date Indicators in Display files

Moving Data

Move Statement MOVE Identifier/Variable or Literal/Constant TO (Indentifier/Variable)s

Numeric Moves Sending Field Receiving Field Okay? Numeric Numeric Field sizes Numeric Alphanumeric Decimal places Packed fields Numeric Group Item

Alphanumeric Moves Sending Field Receiving Field Okay? Alphanumeric Numeric Decimal Places Packed fields Alphanumeric Alphanumeric Field sizes Alphanumeric Group Item

Zero Moves Sending Field Receiving Field Okay? Zeros Numeric Zeros Alphanumerics Zeros Group Item

Spaces Moves Sending Field Receiving Field Okay? Spaces Numeric Spaces Alphanumerics Spaces Group Items

MOVE numeric TO numeric. Field A PIC 9(3) Field B PIC 9(3) 100 Field A PIC 9(3) Field B PIC 9(4) Field A PIC 9(3) Field B PIC 9(2)

MOVE numeric TO numeric. Field A PIC 9(3)V99 Field B PIC 99V9 100.03 Field A PIC 9(3)V99 Field B PIC 9(4)V999 Field A PIC 9(3)V99 Field B PIC 9(3)

MOVE numeric TO alphanumeric. Field A PIC 9(3) Field B PIC X(3) 100 Field A PIC 9(3) Field B PIC X(4) Field A PIC 9(3) Field B PIC X(2)

MOVE numeric TO alphanumeric. Field A PIC 9(3)V99 Field B PIC X(3) 100.03

MOVE numeric TO group item Field A PIC 9(3) Field B. Field C PIC 99. Field D PIC 9. Field A Field B Field C Field D 124

MOVE numeric TO group item Field A PIC 9(3) Field B. Field C PIC 99. Field D PIC 99. Field A Field B Field C Field D 124

MOVE numeric TO group item Field A PIC 9(3) Field B. Field C PIC 9. Field D PIC 9. Field A Field B Field C Field D 124

MOVE numeric TO group item Field A PIC 9(3) Field B. Field C PIC XX. Field D PIC X. Field A Field B Field C Field D 124

MOVE numeric TO group item Field A PIC 9(3) Field B. Field C PIC XX. Field D PIC XX. Field A Field B Field C Field D 124

MOVE numeric TO group item Field A PIC 9(3) Field B. Field C PIC X. Field D PIC X. Field A Field B Field C Field D 124

MOVE alphanum TO alphanum. Field A PIC X(3) Field B PIC X(3) CJM Field A PIC X(3) Field B PIC X(4) Field A PIC X(3) Field B PIC X(2)

MOVE alphanum TO group item Field A PIC X(3) Field B. Field C PIC XX. Field D PIC X. Field A Field B Field C Field D CJM

MOVE alphanum TO group item Field A PIC X(3) Field B. Field C PIC XX. Field D PIC XX. Field A Field B Field C Field D CJM

MOVE alphanum TO group item Field A PIC X(3) Field B. Field C PIC X. Field D PIC X. Field A Field B Field C Field D CJM

MOVE alphanum TO numeric. Field A PIC X(3) Field B PIC 9(3) ABC

MOVE zeros TO numeric. Field B PIC 9(3) Field B PIC 9(4)V99

MOVE zeros TO alphanumeric. Field B PIC X(3) Field B PIC X(1)

MOVE zero TO group item Field B. Field D PIC 9. Field C PIC 99. Field D PIC 9. Field B Field C Field D

MOVE zeros TO group item Field B. Field C PIC XX. Field D PIC XX. Field B Field C Field D

MOVE spaces TO numeric. Field B PIC 9(3) Field B PIC 9(4)V99 Note: This is not supposed to work!

MOVE spaces TO alphanumeric. Field B PIC X(3) Field B PIC X(1)

MOVE spaces TO group item Field B. Field C PIC 99. Field D PIC 9. Field B Field C Field D Note: this is not supposed to work!

MOVE spaces TO group item Field B. Field C PIC XX. Field D PIC XX. Field B Field C Field D

On your own, figure out how Group Item to Group Item and Group Item to Alphanumeric work!

Selection Statements

Sorting on the iSeries EBCDIC Sort 1. Blanks 2. Special Characters 3. Lower Case Letters 4. Upper Case Letters 5. Numbers

Selection Condition? Statement2 Statement1

Selection IF Condition THEN Statement(s) ELSE END-IF

If-Then-Else A = 10 B = 20 If (A > B) THEN MOVE B TO A.

If-Then-Else A = 10 B = 20 If A > B THEN MOVE B TO A ELSE MOVE A TO B.

If-Then-Else A = 10 B = 20 C = 30 D = 40 If A < B THEN IF A > C THEN MOVE A TO C ELSE MOVE C TO A END-IF MOVE A TO B END-IF.

Sign Test A = 10 B = -10 If A IS NEGATIVE IF A IS POSITIVE MOVE B TO A MOVE B TO A ELSE ELSE MOVE A TO B. MOVE A TO B.

Numeric Test A = 10 B = -10 If A IS NUMERIC ADD A TO B.

Alphabetic Test C = ‘CJ’ D = ‘Christy’ If C is ALPHABETIC THEN MOVE C TO OLDER-SISTER ELSE MOVE D TO OLDER-SISTER END-IF

Alphabetic-Upper Test C = ‘CJ’ D = ‘Christy’ If C is ALPHABETIC-UPPER THEN MOVE C TO OLDER-SISTER ELSE MOVE D TO OLDER-SISTER END-IF

Alphabetic-Lower Test C = ‘CJ’ D = ‘Christy’ If D is ALPHABETIC-LOWER THEN MOVE D TO OLDER-SISTER ELSE MOVE C TO OLDER-SISTER END-IF

AND

OR

AND/OR Order of Operations Brackets First ANDs (From Left to Right) ORs (From Left to Right)

ANDs/ORs A = 10 B = -10 C = 20 If (A<B) OR (B<C) AND (A<C) THEN MOVE A TO C ELSE MOVE A TO B END-IF

ANDs/ORs A = 10 B = -10 C = 20 If ((A<B) OR (B<C)) AND (A<C) THEN MOVE A TO C ELSE MOVE A TO B END-IF

Case Statements

IF-THEN-ELSE Statements IF MARKS >= 80 THEN MOVE ‘A’ TO GRADE ELSE IF MARKS >= 70 THEN MOVE ‘B’ TO GRADE IF MARKS >= 60 THEN MOVE ‘C’ TO GRADE IF MARKS >= 55 THEN MOVE ‘D’ TO GRADE MOVE ‘F’ TO GRADE END-IF ENDIF.

CASE Statements EVALUATE TRUE WHEN MARKS >= 80 MOVE ‘A’ TO GRADE WHEN MARKS >= 70 AND MARKS < 80 MOVE ‘B’ TO GRADE WHEN MARKS >= 60 AND MARKS < 70 MOVE ‘C’ TO GRADE WHEN MARKS >= 55 AND MARKS < 60 MOVE ‘D’ TO GRADE WHEN OTHER MOVE ‘F’ TO GRADE END-EVALUATE.

CASE Statements EVALUATE GRADE WHEN ‘A’ DISPLAY ‘WONDERFUL!!!!’ WHEN ‘B’ DISPLAY ‘GREAT!!!’ WHEN ‘C’ DISPLAY ‘NEED ANY HELP?’ WHEN ‘D’ DISPLAY ‘COME AND SEE ME!’ WHEN ‘F’ DISPLAY ‘SEE YOU NEXT SEMESTER’ WHEN OTHER DISPLAY ‘WE HAVE A PROBLEM!’ END-EVALUATE.

Problem ANNAME is a 20 character field in the file, ANMPF that stores an animal name. ANMPF is a Physical file that contains a record for each of animals clients at the Seneca Vet Clinic. You are required to write a COBOL program that selects all of the animals listed in ANMPF that start with a C. What COBOL statement would select all of the animals names that start with the letter ‘C’.

System Date Function current-date Function convert-date-time

Indicators in Display Files

Option Indicators in COBOL Binary Values Working Storage Definition example 01 ws-indicator-list. 05 IN88 INDICATOR 88 PIC 1 value B’0’. Passed to display files in the write statement Write Display-record format is ‘RECORD1’ indicators are ws-indicator-list.

Example – Indicator 90 displays the message, Employee Name is invalid Working Storage. 01 ws-indicators. 05 IN90 INDICATOR 90 pic 1. Procedure Division. If scr-employee-name is equal to spaces move b’1’ to IN90 else move b’0’ to IN90 end-if.

Response Indicators in COBOL Stored as binary values in the display file and passed as PIC X(2) via the control Area. Select Display-file assign to workstation-dspfile-si organization is transaction control area is ws-control. Working Storage Section. 01 ws-control. 05 ws-function-key pic x(2).

Example – check to see if function key 3 was pressed. Select Display-file assign to workstation-dspfile-si organization is transaction control area is ws-control. Working Storage Section. 01 ws-control. 05 ws-function-key pic x(2). Procedure Division. if ws-function-key = ’03’ ….. end-if.

Display file ‘Both’ Fields Input and Output buffers REDEFINES clause Different data specifications for same memory location Screens with both fields need an input and an output buffer.