DT266/2 COBOL Basics – Declaring Data Basic Operations.

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

Tables1 TABLES (chp. 12) group of storage locations (i.e. elements) with the same name accessed by name and subscript ex. var-name (sub) similar to arrays.
Structured COBOL Programming
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)
Check Digit - Mod 11 Please use speaker notes for additional information!
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
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)
The IDENTIFICATION and ENVIRONMENT DIVISIONS Chapter 2.
VB .NET Programming Fundamentals
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
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)
Programming in COBOL-85 For IBM Mainframe System 390
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)
Lesson 1: Introduction to ABAP OBJECTS Todd A. Boyle, Ph.D. St. Francis Xavier University.
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.
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
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.
CS CS Computing for Business Instructor:David Tucker GTA:Batul Mirza.
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).
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.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
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.
1 IDENTIFICATION and ENVIRONMENT DIVISIONS. 2 Objectives Basic Structure of COBOL Programs General Coding and Formatting Rules Identification and the.
Structured Programming
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.
Chapter 2 Using Variables and Constant. What is a Constant ? The data in COBOL programs falls in two broad categories: – Constants and Variables A constant.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
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.
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!
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.
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.
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 2 Introduction to C++ Programming
Structured Programming
Objectives Identify the built-in data types in C++
Programming in COBOL.
Designing and Debugging Batch and Interactive COBOL Programs
Any Questions?.
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Structured COBOL Programming
Programming in COBOL-85 For IBM Mainframe System 390
Agenda Collating sequence / Sorting data
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
CHAPTER 17 The Report Writer Module
Using screens and adding two numbers - addda.cbl
Any Questions?.
Programming in COBOL.
Presentation transcript:

DT266/2 COBOL Basics – Declaring Data Basic Operations

Program Development Design Program Write Code Compile Test Release Maintain

COBOL Program Structure Program = sequence of statements COBOL program consists of 4 divisions IDENTIFICATION DIVISION ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION Identification is mandatory Others optional but must appear in order given above if they do appear

Divisions Identification Division Used to identify the program Only required entry is PROGRAM-ID Can include authors name, date, comments on function as comments Environment Division Used to associate program with the computer system on which it will run Leave blank for now – will deal with in file handling

Divisions Data Division Used to specify the type of data used I.e. files, records, other items Two Sections FILE SECTION WORKING-STORAGE SECTION Procedure Division Contains instructions to achieve program function

COBOL Structure DIVISIONS SECTIONS PARAGRAPHS SENTENCES STATEMENTS CLAUSES

COBOL Line of Code 80 character line – position is important Column 1-6 = sequence number Column 7 = indicator * means comment - word continued from previous line Area A = Columns 8 – 12 Division headers, section headers, paragraph names, some data description Area B = Columns 12 – 72 Code statements

COBOL Restrictions Beware of case Use full stop Terminate division, section, paragraph headers Data item definitions Most code statements Exceptions statements within IF or PERFORM

Program Development Design Sequence Selection Iteration Writing code in COBOL Data Division & Procedure Division Compiling Converts COBOL code to machine code Machine code = object program Executing Code from procedure division is run

Data Division All data used in code statements must be defined in data division Data items (variables) Arrays Records Files Two sections FILE SECTION (will deal with later) WORKING-STORAGE SECTION

Data items – Level Number Permissible numbers 01-49, levels must be in Area A column 8-11 Allow data items to be sub-divided into different levels 01 Customer-name. 03 Customer-TitlePic x(3). 03 Customer-Firstname. 05 Customer-InitialPic x.P 05 Customer-AllPic x(20). 03 Customer-SurnamePic x(20). Levels above 01 must be subordinate to a data item of level 01 Sub levels must be indented one tab from their parent

Data Item – Level Numbers Can be used to group items for clarity e.g 01WS-COUNTERS. 03 COUNT-EGGSPIC COUNT-BACON PIC 9.

Data Item - Names Can consist of characters a-z, A-Z, 9 and – May be up to 30 characters long - cannot be the first or last letter All names must include one alphabetic character Cannot be a RESERVED word (see handout)

Data Items - Picture Describes the length and type of data that can be contained in the item TypeDescriptionDefinition AlphabeticAlphabetic characters A Numeric0-99 CharacterAny characterX

Data Item - Picture E.g 01MY-NAMEPIC A(10). 01 MY-AGEPIC 9(3). LAWLESA 002

Data Item – Value Clause You can set the initial value of a data item at definition time using the Value clause E.g 01 MY-AGEPIC 9(3)VALUE MY-NAMEPIC A(10) VALUE LAWLESS. Always provide an initial value for data items used to control program execution

Basic Instructions Procedure division is sequence of English like statements Getting Data In from keyboard ACCEPT For Fujitsu many have to include from console at end of this statement Sending Data To Screen DISPLAY with no advancing Move data from one item to another Move to Terminate Program STOP RUN.

Basic Maths MOVE A TO B ADD A TO B ADD A TO B GIVING C BEFORE AB 1020 AFTER AB 10 BEFORE AB 1020 AFTER AB 1030 BEFORE ABC AFTER ABC

Basic Maths SUBTRACT A FROM B SUBTRACT A FROM B GIVING C What will be in C after? MULTIPLY A BY B MULTIPLY A BY B GIVING C BEFORE AB 1020 AFTER AB 10 BEFORE AB 1020 AFTER AB BEFORE ABC AFTER ABC

Basic Maths DIVIDE A BY B DIVIDE A BY B GIVING C BEFORE AB 2010 AFTER AB 210 BEFORE ABC AFTER ABC 20102