Introduction to COBOL. COBOL  COBOL is an acronym which stands for Common Business Oriented Language.  The name indicates the target area of COBOL applications.

Slides:



Advertisements
Similar presentations
DT266/2 COBOL Basics – Declaring Data Basic Operations.
Advertisements

2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Introduction to C Programming
2440: 211 Interactive Web Programming JavaScript Fundamentals.
Introduction to C Programming
Chapter 1: Introduction
- Kav Shrestha.  Introduction  History  Features  COBOL Usage  Characteristics  Structure of COBOL Programs  COBOL Divisions  Data Items  Variable.
BY: JOSHUA THOMAS IGNATIUS TOWERS COBOL. Overview What is COBOL History Design Implementations What did it do Program structure Data types Syntax Sample.
The IDENTIFICATION and ENVIRONMENT DIVISIONS Chapter 2.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
Introduction to C Programming
COBOL COmmon Business Oriented Language  Work began in 1959 and has never stopped.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Fundamentals of Python: From First Programs Through Data Structures
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)
Programming in COBOL-85 For IBM Mainframe System 390
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
COBOL Basics 1. COBOL coding rules  Almost all COBOL compilers treat a line of COBOL code as if it contained two distinct areas. These are known as;
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.
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.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
1 Relational Expressions Relational expressions: –Expressions that compare operands –Sometimes called conditions –Evaluated to yield a result –Typically.
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.
1 Interactive vs Batch Programs Cobol suited for developing both types of programs Interactive programs Accept input data from keyboard Input data processed.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
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).
Week 1 Algorithmization and Programming Languages.
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.
Introduction to programming in the Java programming language.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
1 IDENTIFICATION and ENVIRONMENT DIVISIONS. 2 Objectives Basic Structure of COBOL Programs General Coding and Formatting Rules Identification and the.
Chapter 3 Decision Making. What is IF? The primary method of changing the flow of a program is by making decisions using the IF verb. The following example.
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)
CPS120 Introduction to Computer Science Iteration (Looping)
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 Fundamentals. The setw Manipulator setw changes the field width of output. The setw manipulator causes the number (or string) that follows.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
The PERFORM. The PERFORM Verb  Iteration is an important programming construct. We use iteration when we need to repeat the same instructions over and.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
371 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
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.
FG Group -Afrilia BP -Liana F.B.I -Maulidatun Nisa -Riza Amini F.
STRUCTURED PROGRAMMING Complete C++ Program. Content 2  Main Function  Preprocessor directives  User comments  Escape characters  cout statement.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Structured Programming
Programming in COBOL.
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
DATA TYPES There are four basic data types associated with variables:
Programming in COBOL.
Presentation transcript:

Introduction to COBOL

COBOL  COBOL is an acronym which stands for Common Business Oriented Language.  The name indicates the target area of COBOL applications.  COBOL is used for developing business, typically file-oriented, applications.  It is not designed for writing systems programs. You would not develop an operating system or a compiler using COBOL.  COBOL is one of the oldest computer languages in use (it was developed around the end of the 1950s). As a result it has some idiosyncracies which programmers may find irritating.

The COBOL Metalanguage - Syntax Notation  Words in uppercase are reserved words.  Words in mixed case represent names which will be devised by the programmer.  When material is enclosed in braces { } a choice must be made from the options within the braces.  Material is enclosed in square brackets [ ] indicates that the material is an option which may be included or omitted as required.  The ellipsis symbol ‘...’ indicates that the preceding syntax element may be repeated at the programmer’s discretion.

ProgramProgram DivisionsSection(s)Paragraph(s)Sentence(s)Statement(s) Structure of COBOL programs.

The Four Divisions. DIVISIONS are used to identify the principal components of the program text. There are four DIVISIONS in all.  IDENTIFICATION DIVISION.  ENVIRONMENT DIVISION.  DATA DIVISION.  PROCEDURE DIVISION. Although some of the divisions may be omitted the sequence in which the DIVISIONS are specified is fixed and must follow the pattern shown above.

Functions of the four divisions.  The IDENTIFICATION DIVISION is used to supply information about the program to the programmer and to the compiler.  The ENVIRONMENT DIVISION describes to the compiler the environment in which the program will run.  As the name suggests, the DATA DIVISION is used to provide the descriptions of most of the data to be processed by the program.  The PROCEDURE DIVISION contains the description of the algorithm which will manipulate the data previously described. Like other languages COBOL provides a means for specifying sequence, selection and iteration constructs.

COBOL Program Text Structure Data Descriptions Algorithm Description IDENTIFICATION DIVISION. DATA DIVISION. PROCEDURE DIVISION. Program Details

IDENTIFICATION DIVISION.  The purpose of the IDENTIFICATION DIVISION is to provide information about the program to the programmer and to the compiler.  Most of the entries in the IDENTIFICATION DIVISION are directed at the programmer and are treated by the compiler as comments.  An exception to this is the PROGRAM-ID clause. Every COBOL program must have a PROGRAM-ID. It is used to enable the compiler to identify the program.  There are several other informational paragraphs in the IDENTIFICATION DIVISION but we will ignore them for the moment.

The IDENTIFICATION DIVISION Syntax.  The IDENTIFICATION DIVISION has the following structure IDENTIFICATION DIVISION. PROGRAM-ID. NameOfProgram. [AUTHOR. YourName.]  The keywords IDENTIFICATION DIVISION represent the division header and signal the commencement of the program text.  The paragraph name PROGRAM-ID is a keyword. It must be specified immediately after the division header.  The program name can be up to 30 characters long.

The IDENTIFICATION DIVISION Syntax.  The IDENTIFICATION DIVISION has the following structure IDENTIFICATION DIVISION. PROGRAM-ID. NameOfProgram. [AUTHOR. YourName.]  The keywords IDENTIFICATION DIVISION represent the division header and signal the commencement of the program text.  The paragraph name PROGRAM-ID is a keyword. It must be specified immediately after the division header.  The program name can be up to 30 characters long. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. SequenceProgram. AUTHOR. Team Sarmag. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. SequenceProgram. AUTHOR. Team Sarmag.

The DATA DIVISION.  The DATA DIVISION is used to describe most of the data that a program processes.  The DATA DIVISION is divided into two main sections; l FILE SECTION. l WORKING-STORAGE SECTION.  The FILE SECTION is used to describe most of the data that is sent to, or comes from, the computer’s peripherals.  The WORKING-STORAGE SECTION is used to describe the general variables used in the program.

 The DATA DIVISION has the following structure DATA DIVISION Syntax $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Sequence-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Sequence-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS.

The PROCEDURE DIVISION.  The PROCEDURE DIVISION is where all the data described in the DATA DIVISION is processed and produced. It is here that the programmer describes his algorithm.  The PROCEDURE DIVISION is hierarchical in structure and consists of Sections, Paragraphs, Sentences and Statements.  Only the Section is optional. There must be at least one paragraph, sentence and statement in the PROCEDURE DIVISION.  In the PROCEDURE DIVISION paragraph and section names are chosen by the programmer. The names used should reflect the processing being done in the paragraph or section.

Sections  A section is a block of code made up of one or more paragraphs.  A section begins with the section name and ends where the next section name is encountered or where the program text ends.  A section name consists of a name devised by the programmer or defined by the language followed by the word SECTION followed by a full stop. l SelectUlsterRecords SECTION. l FILE SECTION.

Paragraphs  Each section consists of one or more paragraphs.  A paragraph is a block of code made up of one or more sentences.  A paragraph begins with the paragraph name and ends with the next paragraph or section name or the end of the program text.  The paragraph name consists of a name devised by the programmer or defined by the language followed by a full stop. l PrintFinalTotals. l PROGRAM-ID.

Sentences and Statements.  A paragraph consists of one or more sentences.  A sentence consists of one or more statements and is terminated by a full stop. l MOVE.21 TO VatRate COMPUTE VatAmount = ProductCost * VatRate. l DISPLAY "Enter name " WITH NO ADVANCING ACCEPT StudentName DISPLAY "Name entered was " StudentName.  A statement consists of a COBOL verb and an operand or operands. l SUBTRACT Tax FROM GrossPay GIVING NetPay l READ StudentFile AT END SET EndOfFile TO TRUE END-READ

A Full COBOL program. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. SequenceProgram. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. CalculateResult. ACCEPT Num1. ACCEPT Num2. MULTIPLY Num1 BY Num2 GIVING Result. DISPLAY "Result is = ", Result. STOP RUN. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. SequenceProgram. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. CalculateResult. ACCEPT Num1. ACCEPT Num2. MULTIPLY Num1 BY Num2 GIVING Result. DISPLAY "Result is = ", Result. STOP RUN.

The minimum COBOL program. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. SmallestProgram. PROCEDURE DIVISION. DisplayPrompt. DISPLAY "I did it". STOP RUN. $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. SmallestProgram. PROCEDURE DIVISION. DisplayPrompt. DISPLAY "I did it". STOP RUN.