sir.jpg (7207 bytes)

HISTORY OF COBOL LANGUAGE

1959 - a group of computer professionals from various organization gathered to design a uniform, machine independent computer programming language for business use. This group met under the name of CODASYL (Conference on Data systems language)

1960 - COBOL-60 - the first version of COBOL because it was released in 1960. Three revesions followed� COBOL-68, COBOL-74, and most recently COBOL-85


COBOL DISTINGUSHING FEATURES

Major:

  • Machine Independent - Cobol can be executed on many different computers with little or no modifications

  • Ex: Cobol written on VAX will run on IBM computer.

  • Program Maintainance - it would be easy to maintain

  • Documentation - it would be self-documenting.

Minor:

  • Cobol programs are uniquely organized. - Program is divided into four standards parts called, divisions.

  • Cobol is well suited for commercial data processing - most of the data processing performed in business requires two major tasks: simple calculations and I/O large quantities of data.

  • The data in Cobol are organized into records - Each record contains a collection of data.

  • Cobol programs process several types of files - sequential, index sequential, and relative. A file consists of group of records.

  • A cobol program can read and write massive amounts of data using only few statements. This is referred to as I/O process.


PROGRAM DEVELOPMENT CYCLE

ANALYSIS
understanding the the purpose of the program - understanding what the program is to accomplish. Using the Program specification

DESIGN
Lay outing the program. The programmer determines how the program is to be written to meet the stated specification. This is accomplished by using some design tools; hierarchy chart, structured flowchart, pseudocode.

CODING
writing the codes. The step by step instructions in a programming language.

TESTING/DEBUGGING
determinining the end result of the program

TERMINOLOGIES

  1. Program A sequence of instruction that the computer executesto solve a programming problem.

  2. Programming Language A language that can be used to instruct a computer to solve a programming problem.

  3. COBOL The most widely used computer programming for business application

  4. Machine Language The only language that the computer directly execute. It consists of series of ones and zeros

  5. Machine Dependent Language A language that varies depending on the type of computer being used.

  6. High level Programming Language Programing language that uses english-like words and phrases.

  7. CODASYL Conference on Data Systems Language

  8. ANSI American National Standard Institute

  9. Machine Independednt Language A Programming language that can be executed on many different computers with little or no modifications

  10. Program Maintainance The activity of modifying pre-existing program

  11. Documentation Written statements that explain a program to humans

  12. Object Oriented Programming (OOP) A new technique of writting computer p[programs, in which data and operations to be performed on the data are link togetherinto objects.

SAMPLE PROGRAM
FIRSTONE.CBL

Almost every programming text begins with a small program which displays on screen a message. "HELLO, WORLD", "HERE I AM", "THIS IS MY FIRST PROGRAM" or some such thing.

And here it is:

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. FIRSTONE.
000300 AUTHOR. G HARRIS.
000400*****************************************************
000500*THIS PROGRAM WILL DISPLAY THE MESSAGE HERE I AM
000600*****************************************************
000700
000800 ENVIRONMENT DIVISION.
000900 CONFIGURATION SECTION.
001000 SOURCE-COMPUTER. IBM-PC.
001100 OBJECT-COMPUTER. IBM-PC.
001200
001300 DATA DIVISION.
001400 WORKING-STORAGE SECTION.
001500 01 DISPLAY-MESSAGE PIC X(9) VALUE 'HERE I AM'.
001600
001700 PROCEDURE DIVISION.
001800 000-STARTER.
001900 PERFORM 100-DISPLAY.
002000 PERFORM 999-ENDER.
002100 100-DISPLAY
002200 DISPLAY 'HERE I AM'.
002300 DISPLAY DISPLAY-MESSAGE.
002400 999-ENDER.
002500 STOP RUN.

If you take a look at the code you will notice several things right away.

- NUMBERS/SPACING -

First, you will note that each line is numbered. This is not essential, and if your Text Editor does not do this, don't worry. The code can be compiled without these numbers, and as a matter of fact if your Editor doesn't automatically put them in, don't you do it either. It may screw up the compiler. But, numbers do have two very important advantages:

- Numbers make it much easier to debug a program because you can find line ���� number easily. Compilers give line numbers when error messages are generated.� -Numbers take up six spaces.

The first six places in COBOL code represent a throwback to the days when coding was done on punchcards. If the cards got shufflled they could be put back in order by number. Punchcards are no longer used, but the first six spaces are still held for them. Go figure. Characters are never placed in the first six places.

Spacing is very important in COBOL. All COBOL code has to start after space number 7, except for a few particular directive symbols. Column 7 is used for only three things. they are:

(1) Comments. Take a look at line 400 (see, I told you line numbering was a good idea). Te character in column 7 is an * (asterisk). This indicates a comment line. The compiler will not recognize anything after the *. I create a box just for readability but you don't have to. Just one * in column 7 blanks the whole line from the compiler;

(2) Page-Eject. If we want to print our source code we can use a / (slash) in column 7 to tell the printer to move to the next page before continuing to print. This is convenient for long programs where you want to have natural divisions between code sections;

3) Continuation. The standard Text Editor is 80 spaces wide. You only have 72 spaces to use in a COBOL program (we'll get to that). If you are writing code and come to the end of the editor line, but want to continue the code, you can place a "-" (dash) in column 7 of the next edit line. It's really simple, and we will try it in the next program. A comment about comments. You should use comments throughout your code to document your program, identifying things which you or someone else may need to find quickly later on. Also use comments to explain processes which are unclear within the code. This is an extremely valuable debugging tool.

A comment about comments. You should use comments throughout your code to document your program, identifying things which you or someone else may need to find quickly later on. Also use comments to explain processes which are unclear within the code. This is an extremely valuable debugging tool.

- DIVISIONS -

The next thing you should notice is that the code has four DIVISIONS, which are:

I have separated these with spaces in the code for easy identification. That is not the convention in writing code, and will not be done again. But, if it makes it easier for you, it won't hurt.

Just a comment about "white space". Some other languages like C++ allow code to be written almost anywhere within the text editor. In COBOL you need to be very careful where you place code. You can have as many blank lines between two lines of code as you want, but you can't place the code anywhere within a line.

Each of these DIVISIONS is mandatory in a COBOL program. You gotta have 'em or the program won't compile. Not only that, they have to be in the exact order as above.

Notice that the Divisions start at column 8. A coding line is divided into three parts, Column 7 (as noted above), Area-A and Area-B.

Area-A is made up of spaces 8-11. All DIVISION statements must begin within this Area. Usually they begin in column 8 but they don't have to, as long as they begin before space 12.

All SECTION statements must begin in Area-A.

All PARAGRAPH NAMES must begin in Area-A.

Area-B is made up of spaces 12-72. This area is for most COBOL entry code. Code in Area-B can begin anywhere within this space.

Columns 73-80 are not recognized by the compiler. Writing code in these columns will no doubt result in an Error Message when compiled. (The compiler will reject the code, send you an error message and shut down).

IDENTIFICATION DIVISION

The IDENTIFICATION DIVISION is used to identify the program. The following PARAGRAPHS may be included under the IDENTIFICATION DIVISION, although only the term IDENTIFICATION DIVISION and the paragraph PROGRAM-ID and its Program Name are mandatory;

IDENTIFICATION DIVISION. (mandatory)
PROGRAM-ID. FIRSTONE. (mandatory on some compilers)
AUTHOR. (optional)
INSTALLATION. (optional)
DATE-WRITTEN. (optional)
DATE-COMPILED. (optional)
SECURITY. (optional)

Note: Many words have a hyphen between them. Gotta have it in order for the program to compile. Make two words out of PROGRAM-ID and the program won't work.

ENVIRONMENT DIVISION

The ENVIRONMENT DIVISION identifies computer information by using two SECTIONS, the CONFIGURATION SECTION and the INPUT-OUTPUT SECTION. Notice that the IDENTIFICATION DIVISION uses PARAGRAPHS, not SECTIONS.

ENVIRONMENT DIVISION. (mandatory)
CONFIGURATION SECTION. (optional)
INPUT-OUTPUT SECTION. (used when needed)
FILE CONTROL (used with INPUT-OUTPUT SECTION)

The CONFIGURATION SECTION allows you to identify the computer used to write the program (SOURCE-COMPUTER) and the computer used to compile/run the program. This is more useful on mainframe or VAX than for PC's. I usually do it out of habit.

The INPUT-OUTPUT SECTION, including FILE CONTROL will be discussed later.

DATA DIVISION

The DATA DIVISION defines records, fields, storage files used in the program. It includes the FILE SECTION (described later) and the WORKING-STORAGE SECTION.

DATA DIVISION. (mandatory)
FILE SECTION. (used when needed)
WORKING-STORAGE SECTION. (use when needed)

The WORKING-STORAGE SECTION is used to store information which will be used later in the program for processing. In program FIRSTONE.CBL the only thing we are storing is the value HERE I AM. Later you will see that this section is used for a great many storage items.

PROCEDURE DIVISION

The PROCEDURE DIVISION is the area where the processing of the program is done. This is where you write the code that makes the program perform the activity you want.

Back


Copyright � 2002 nrmoratalla
All rights reserved.

Hosted by www.Geocities.ws

1