Top 3 Products & Services


Dated: Aug. 12, 2004

Related Categories

COBOL Programming


COBOL is a high level programming language of the procedural type. That is, it is not a functional, logic-oriented or object-oriented language. It is used primarily in the implementation phase of software development, like most programming languages. Sometimes, though, low-level designs are written in a COBOL-like pseudo code. A COBOL programmer writes a program using keyboard entry of text, because the most common human to computer medium at the time of its invention was the punch card.

The name COBOL is an acronym that expands to Common Business Oriented Language. It was designed to be used in business applications. Today, we would say Information Systems. It continues to be most commonly used in Information Systems applications.

History of Cobol

In 1959, the U. S. Defense Department created a group called The Short-range Committee, which, over a period of a few months, defined the COBOL language. The committee was organized by the Conference On Data System Languages (CODASYL). A midrange committee was also organized and a long-range committee was defined but never created. The Short-range committee consisted of representatives from: National Bureau of Standards, US Air Force, RCA, Burroughs, the Navy, Sylvania and Sperry Rand. The first COBOL compiler was implemented in 1960. The committee was selected to be a combination of computer manufacturers, which were expected to implement COBOL, and expected users of COBOL.
These committee members were practitioners, with almost no representation of academically oriented researchers. The Short-Range Committee worked largely from knowledge of the existing Flow-Matic language, developed by Grace Hopper, and IBM's specification of its planned Commercial Translator. (Sammet, 1978) (IEEE, 1999)

The committee intended the language to have good file support, including support for sequential, key-indexed and direct access files. They wanted the language to be readable, even by the programmers' managers. Several design principles guided the design of COBOL.

  • separate data & procedures
  • machine dependent statements in one place
  • naturalness
  • ease of transcription to require media (cards at the time)
  • effectiveness of problem structure
  • ease of implementation (for compiler writers)
  • physically available character set (printable)
  • noise words
  • long data names (Sammet, 1978)

Even for a standardized language, implementers add extensions to the language to gain a market advantage or to make use of features in their hardware. For example, IBM includes pointer variables and the "address of" clause to set a pointer. It also offers the option to turn on subscript range checking at run time. (IBM, 1993) Several implementers offer editors sensitive to the COBOL syntax and even a complete interactive development environment.

COBOL continues to progress with work being done in the Object-Oriented COBOL standard. The ISO/IEC has issued Committee Draft 1.8 in February of this year. (ISO/IEC, 2000) Even before the standard is finalized, Hitachi, IBM, Microfocus (now part of Merant) and others are offering object-oriented COBOL compilers.

Who Uses Cobol

COBOL has had four decades, since it was defined, to become entrenched in the business computing community. As a programming language, COBOL is intended to be used, and is primarily used during software implementation. However, sometimes low-level designs are written in a COBOL-like pseudo code.

Although estimates of the extent of COBOL's use vary, they all indicate that COBOL is very widely used. Robert Glass (1997) estimates that two-thirds of all the world's programmers use COBOL. Estimates of the number of COBOL programmers range from 2.5 million (Keuffel 2000) to 3 million (Fussichen, 1990). A recent voluntary response survey by Carr and Kizior (2000) on the future of COBOL education indicates that more than 87% of the business respondents’ current develop and maintain COBOL applications, as illustrated in figure 5. They also said that more than 45% of the respondents would continue to use COBOL through the next decade, although 30% thought their use of COBOL would decline.

Estimates of the amount of COBOL code in productive use vary widely, but they do not contradict each other. Arranga (2000) estimates between 18 billion and 200 billion lines of COBOL code are running production applications worldwide. Estimates of 80 billion by Fusichen (1990), 150 to 175 billion lines by Wheatley in (Arranga, 1999) and 180 billion by Hardgrave and Doke (2000) fall within that range. The last authors also estimate that 5 billion lines of new COBOL code are written each year. Addressed from the perspective of software applications written, Arranga and Price (2000) say that 35% of all new business application development is written in COBOL.

Is Cobol a Best Practice

To determine if COBOL really is a best practice among software engineering practices, we must divide the question into two parts. Was COBOL a best practice when it was first introduced? Is COBOL still a best practice today? Since four decades have elapsed since its introduction, and both COBOL and software engineering have changed over time, we must ask this two-part question. We also note that a good programming language must be readable to make programs maintainable and it must include modern language constructs.

Was It a Best Practice in 1959 ?

Was COBOL a best practice when it was introduced in 1959? Like every high level language is intended to be, COBOL was further from the machine language and assembler language, which were in common use at the time. This distance made it closer to human natural language. It was only the second high-level language, after FORTRAN to become and stay popular. Unlike FORTRAN, COBOL was intended to be readable by business programmers and even by their managers. It is probably the only programming language that can be read aloud and make sense. By being readable, it is more easily written. Programmers can easily remember the verbs and required structure, because they combine to make readable sentences. A COBOL statement is even called a sentence and it usually ends with a period. The only drawback to readability is that COBOL can be wordy. Language readability is a prerequisite to maintainability. This is important in the Information Systems industry where programs get modified and enhanced for twenty or more years without being replaced

The development of COBOL made many contributions to the field of high level programming languages, some of which have carried over to other languages. Its development was a joint effort that was clearly successful. It separated the data description from the procedural statements.

Re-engineering Cobol into CIntrinsic Control

Joiner & Tsai (1994) report on a tool for re-engineering a COBOL application into the C language. The paper lists five conclusions about the COBOL programs that they studied. Four of the conclusions imply that the existing COBOL programs are well structured and easy to understand.

COBOL applications are constructed of many small programs.

Existing record variables make good candidates for instance variables since many represent the state of entities in the application domain.”
“Existing paragraphs make good candidates for methods since they are generally small and define few variables.”
"Minimal ‘hand’ re-engineering is needed because the programs use few messy constructs such as GOTOs, ALTERS or fall-throughs.”

According to the report, translation of COBOL into C is desirable because COBOL lacks local variables and cannot pass parameters to called procedures. The second statement has never been true, because COBOL has always had the CALL statements, which can invoke and pass parameters to an external procedure. Again, ANSI 85 COBOL has completely eliminated both deficiencies with the introduction of nested programs. Any number of whole subprograms can be nested inside a main program, and those subprograms can themselves contain whole subprograms, in a single compilation unit. These subprograms are invoked with a CALL statement that passes parameters. Thus, the main program and each subprogram can own local variables whose scope is limited to that subprogram. Joiner and Tsai present only those two reasons for changing to C, leaving COBOL programmers familiar with nested programs no good reason to change their key,

Lets the Game Begin

Start with the Basics of Cobol

The best way to learn to programme/learn a new language is to actually be able to write code and run it on a computer. Consequently, you really need a computer (probably a PC), a text editor (Notepad or WordPad will do) to write the code into, and most importantly, a COBOL compiler which will check your code and then convert it into something the computer can understand and execute. I use the Fujitsu COBOL85 ver3.0 compiler which can be downloaded for free

Coding Areas :

If you look at the COBOL coding all the specific positions of coding elements are important for the compiler to understand. Essentially, the first 6 spaces are ignored by the compiler and are usually used by the programmer for line numbers. These numbers are not the same as those in BASIC where the line number is used as part of the logic (e.g. GOTO 280, sending the logic to line 280).

The seventh position is called the continuation area. Only certain characters ever appear here, these being:

* (asterisk), / (solidus or forward slash), or - (hyphen).

The asterisk is used to precede a comment, i.e. all that follows is ignored by the compiler. The solidus is used to indicate a page break when printing coding from the compiler, but it too can be used as comment since the rest of the line is ignored by the compiler. The hyphen is used as a continuation marker, i.e. when a quoted literal needs to be extended over to the next line. It is not for continuing a statement onto the next line (this is unnecessary*) and also cannot be used to continue a COBOL word. (*You can write any COBOL statement over as many lines as you like, so long as you stay in the correct coding region and don't split strings.)

000200*Here is a comment.Cobol Tutorial
000210/A new line for printing and a comment.
000220 :
000340 DISPLAY 'This might be a very long string that
000350- 'needs to be continued onto the next line'

Positions 8 to 11 and 12 to 72 are called area A and area B, respectively.


Identifier names User-defined names must conform to the following rules:

  • Must only consist of alphabetic and numeric characters and/or hyphens
  • The name must contain at least one alphabetic character
  • Must be no more than 30 characters
  • When using hyphens, they must not appear at the beginning or end of the name

Some examples of legal names:

  • A123
  • RecordCount-1
  • Tot-2-out

Like all COBOL code, the compiler will not distinguish between upper and lower case letters (except within quotes). Lastly, COBOL has a large list of reserved words that cannot be used as identifier names.


The full stop (period) is the most important punctuation mark used, and its use will be detailed later, Generally, every line of the IDENTIFICATION, ENVIRONMENT, and DATA DIVISION end in a period.

Quotation marks, either single or double, are used to surround quoted literals (and when calling a sub-program). However, don’t mix them when surrounding the literal, e.g.

" This is bad ’
" but this is ok "

Commas and semi-colons are also used to separate lists of identifiers, e.g. MOVE 2 TO DATA-ITEM-1, DATA-ITEM-2, DATA-ITEM-3 A space must follow the comma/semi-colon. They are optional however, and a space would suffice, but it does add to clarity.


Since COBOL was developed in the USA, the spelling of words is American, e.g. INITIALIZE or ORGANIZATION (using Z rather than S). Brits be warned!
In many cases, abbreviations and alternative spellings are available (see reserved word list), e.g. ZERO ZEROS ZEROES all mean the same thing. Likewise, LINE and LINES, PICTURE and PIC, THROUGH and THRU.

Hello World Program

As is traditional for all introductory lessons for a programming language, here's a 'Hello World' program

Data Vision

The different pieces of data need to be defined so that the program can read a record at a time, placing each piece of information into the right area of memory (which will be labelled by an identifier).

COBOL program code is divided into four basic division: IDENTIFICATION, ENVIRONMENT, DATA, and PROCEDURE divisions. The identification division is required, but in theory the others are not absolute (although you won't have much of a program without any procedures or data!).

The data division is where memory space in the computer is allocated to data and identifiers that are to be used by the program. Two important sections of this division are the FILE SECTION and the WORKING-STORAGE SECTION. The file section is used to define the structure, size and type of the data that will be read from or written to a file.

Suppose the 'input.dat' file (described above) contains a series of records about a companies customers, giving details of name, address, and customer number. If you were to open 'input.dat' with a text editor you would see each record on a new line like this:

Joe Bloggs 20Shelly Road Bigtown 023320
John Dow 15Keats Avenue Nowheresville042101
Jock MacDoon05Elliot Drive Midwich 100230


Enviroment Division

This division tells the computer what the program will be interacting with (i.e. its environment) such as printers, disk drives, other files etc... As such, there are two important sections: the CONFIGURATION SECTION (which defines the source and object computer) and the INPUT-OUTPUT SECTION (which defines printers, files that may by used and assigns identifier names to these external features).

000320 SELECT INPUT-FILE ASSIGN TO 'input.dat'

Identification Division

The identification division tells the computer the name of the program and supplies other documentation concerning the program's author, when it was written, when it was compiled, who it is intended for...etc. In fact, only the program name is required by the compiler.

000140 DATE-WRITTEN. 17/5/00.

Procedure Division

The procedure division is where the logic of the program actually found. COBOL is a modular language, in that a program is usually broken up into units described as paragraphs.

000950 STOP RUN.

Boolean Data

Boolean data is either TRUE or FALSE. These are data types are useful for flags for so-called condition-name conditions.

A simple example:



  • When then number entered (line 250) is greater than 1000 then a 'Y' character is moved to the level 01 item NUMBER-SIZE. The effect of this is to give the level 88 item BIG-NUMBER a TRUE condition. This is what level 88 is for in COBOL.
  • Line 240 initially sets BIG-NUMBER to false by moving an 'N' character into NUMBER-SIZE, although any character (other than 'Y') would have the same effect.
  • IF BIG-NUMBER THEN... is like saying "IF BIG-NUMBER is true THEN..."

Multiple level 88 can be set for a single group, or you can have more than one option that will set the condition to true.

    01 THIRTY-DAY-MONTHS PIC X VALUE SPACE.            88 SEPTEMBER  VALUE 'S'.            88 APRIL      VALUE 'A'.            88 JUNE       VALUE 'J'.            88 NOVEMBER   VALUE 'N'.     01 MONTHS-CHECK PIC X.            88 SHORT-MONTH VALUE 'S' 'A'                                 'J' 'N'                                 'F'.    01 GRADES-CHECK PIC 999.           88 A-GRADE    VALUE 70 THRU 100.           88 B-GRADE    VALUE 60 THRU 69.           88 C-GRADE    VALUE 50 THRU 59.           88 FAIL-GRADE VALUE 0 THRU 49. 

GRADES-CHECK uses THRU (or THROUGH) to allow a range of numeric values to be tested.


A useful verb to use is SET. Rather than having to use the line:
as in the code example above, you can simply set the boolean variable to true by coding:
This means that you don't have to worry about what the value of the level 01 item has to be in order to make the associated level 88 to be true (notice that it is the level 88 item name that is set to true and NOT the level 01 item). Of course, you might also code


During a program run it is often necessary to reset an item, or group of items, back to zero (or other value), or back to a certain literal. Often the program requires data to be set at a certain value (or set literal) at the beginning of a run. For example, an item may be used to count the number of records that have been read by the program. each time this has occurred the line:


Obviously, the first time REC-COUNT is encountered, it would need to have a value (probably zero). This could be acheived in the data division:


Alternatively, early in the procedure division, the command


would have the same effect. If, however, you wished to set a group of items to zero (to zeroize) and/or set other alphanumeric items in that group to spaces then you could use the INITIALIZE verb. For example:

     000200 DATA DIVISION.      000210 WORKING-STORAGE SECTION      000220 01 DATA-GROUP.      000230    03 REC-COUNTER   PIC 9(4).      000240    03 REC-TYPE      PIC X(2).      000250    03 REC-DATE      PIC 9(6).      000260    03 FILLER        PIC X(14) VALUE 'Record details'.

And in the procedure division:


The effect of this will be that whatever the contents of any of the level 03 items prior to the initialize statement REC-COUNTER will now contain zero, as will REC-DATE, and REC-TYPE will contain spaces. However, FILLER (the last item), is actually a reserved word and refers to an used area. The word 'FILLER' can actually be omitted (i.e. 01        PIC X(14) VALUE 'Record details'.). As you will see in the Printing/writing data part of the next section, a literal can be assigned to this. Following initialization the filler will remain unchanged (and not space-filled).

Printing and Writing Data

The following code illustrate how a printed report is defined in the data division. If writing to a file it would be virtually identical.

If you wished to print a report in the form of a table then you would first have to assign an identifier name to the printer in the environment division using the select clause.


  • The printout would have the following format:
  • The printer was assigned to PRINT-FILE (the FD level) with the level 01 called REPORT-OUT
  • There are four groups used to define each main part of the printout: PRINT-HEADERS (for the title and column heads), PRINT-LINE (for the actual data from the records), P-FOOTER (for the totals at the end of the table), and P-BATCH which appears after the main table and lists various totals
  • To define text, fillers are used with a VALUE of what the text is to be, e.g.

    001090      03 COL-HEAD-1 PIC X(31) 
    001100          VALUE ' PART    CUST/  DATE    QUANT'.
    This is the first line of the column header. COL-HEAD-2 giving the next line.

  • Spaces between the titles done by defining a PIC X size that is larger then the text since the extra spaces will be space-filled
  • Spaces between data are acheived by the use of fillers with a VALUE SPACES for the desired PIC X size.
  • Data and strings to be printed are first moved to the appropriate item of the print group and then the entire group is written to REPORT-OUT, which is defined as PIC X(80). For example:
    Here the page number is moved to the P-TITLE sub-group member (of PRINT-HEADERS) P-PAGE-NO. The following line effectively means:
    (AFTER PAGE instructs the printer to start a new page)
  • It is in the data groups involved in printing (or writing to a file) that data editing (such as zero-supression) is performed
  • By simply changing the ASSIGN PRINT-FILE TO 'PRINTER' to ASSIGN PRINT-FILE TO 'report.txt' would be all that was required to produce the same report in a file called 'report.txt' and add ORGANIZATION IS LINE SEQUENTIAL. Although, the AFTER PAGE and AFTER ... LINES would have no effect


The preponderance of evidence clearly supports naming COBOL a best practice. It is widely used, and it is taught at many universities. It contains most of the features and constructs required of a modern programming language and it continues to progress into the object-oriented world. Finally, COBOL has features required of a language used for business applications that other languages lack. Unless or until a better language is invented, perhaps a non-hybrid object-oriented business language, some version of COBOL will certainly be used for a long time. COBOL is a software engineering best practice.

Now that you've gotten free know-how on this topic, try to grow your skills even faster with online video training. Then finally, put these skills to the test and make a name for yourself by offering these skills to others by becoming a freelancer. There are literally 2000+ new projects that are posted every single freakin' day, no lie!

Previous Article

Next Article

Vishal Shrimali's Comment
Its provide good knowledge about Computer.
25 Mon Feb 2013
Admin's Reply:

Glad to hear you liked it Vishal.

Ateeq's Comment
thank you alot that was realyy effective for ma listens great
17 Tue Apr 2012
Admin's Reply:

Thanks Ateeq.

Rafa's Comment
Your correctness of your seobrvation about ordinary english and source code depends, of course, on the language. Look at a function I wrote in Mathematica, which takes a list of cusips, selects their monthly returns from yyyymm1 to yyyymm2 as a subset from a much larger set of returns, converts the monthly returns to the form 1+return/100 (as in beginning value * (1+r/100)= ending value, gets the product of the series, and passes back all the products as a list.I don't think this is the greatest description a really clear one would be longer. It seems to me that the Mathematica code is much easier to understand than my description. Maybe my code looks more clear to me then to others because I wrote it. But, I think Mathematica is a superior language, and while reading your comment, it occured to me that such a comparison might be interesting to you (since not many people program in it). dates' (a 1d list) and returntable' (a 2d list) already have their values when the function is called.wealthMultiplier[cusips_, yyyymm1_, yyyymm2_] := Module[{}, b = Position[dates, ToString[yyyymm1]][[1, 1]]; e = Position[dates, ToString[yyyymm2]][[1, 1]]; returns = returntable; returns[[All, 2]] = returns[[All, 2]] /. Map[(# -> "drop") &, Complement[returns[[All, 2]], cusips]]; returns = Select[returns, #[[2]] != drop &]; returns = Drop[Drop[returns, None, {e + 1, -1}], None, {1, b}]; returns = returns /. {Null -> 0}; wealthrelatives = Map[(1 + #/100) &, returns]; wealthmultiplier = Map[Fold[Times, 1, #] &, wealthrelatives] ]
13 Tue Mar 2012
Admin's Reply:

adal's Comment
an error occurred when compiling the cobol program.. error 2001: null pointer exception.. what does this mean? is my os (win7) not compatible to this kind of compiler? pls. help :( how can i fix this error?
23 Mon Jan 2012
Admin's Reply:

B�rge Agermark's Comment
Great tutorial - thanks
15 Fri Jul 2011
Admin's Reply:

 Anytime Barge

Maurice Arnold's Comment
I have seen the error 2001: null pointer assignment mentioned above. It happens with the older compilers like MS Cobol 2,2 when ported to a current computer. However, I don't know if there is a fix for it other than getting a more recent compiler. If anyone does know a fix I would be most grateful for the information.
04 Fri Mar 2011
Admin's Reply:

I hope someone helps you out Maurice. I'm not a COBOL person.

sathya narayanan's Comment
hi, frds... i hate cobol very much...
17 Thu Feb 2011
Admin's Reply:

I hate most programming languages

murali's Comment
i think it is so difficult to use.... but i like it very much.... it is so easy to use....
17 Thu Feb 2011
Admin's Reply:

I think anything that you understand well becomes easy

RAVI's Comment
09 Wed Feb 2011
Admin's Reply:

Thanks Ravi.

javier's Comment
23 Tue Nov 2010
Admin's Reply:


udaykumar's Comment
i need to know about cobol and video tutorials
12 Thu Aug 2010
Admin's Reply:

Simply go to: Computer Tutorial Videos

Do you think is it possibile to apprehend COBOL from 0 (no programming knowledge)? How much time could it take for to achieve professional skills? and Last: COBOL works on mainframes. how to practice in cobol on a computer? Thank's
28 Mon Jun 2010
Admin's Reply:

Thanks for asking Alessandro!

First of all, As a Non-COBOL programmer, I can tell you this from my experience with other programming. Where there is a will, there is a way. COBOL can be a bit tricky at start but like any other programming, the learning curve drops drastically after you learn some of the basic stuff. And then, regarding the mainframe question...

I'm certain that there maybe a software out there to give you a mock mainframe environment on a PC. Similar to how a lot of folks learn Linux and Unix on a PC.

Larry's Comment
have you encountered an error during compilation like this one: error 2001: null pointer assignment. Pls let me know if you have a.ny idea. Thanks!
24 Thu Jun 2010
Admin's Reply:

Nope, did anyone else?

pachiannan's Comment
04 Fri Jun 2010
Admin's Reply:


miguel o. mendez's Comment
Que libros recomiendan para aprender cobol language, existe cobol para pc.
17 Thu Dec 2009
Admin's Reply:

Libros recomendados son:

Jerry Sitner's Comment
Is COBOL a best practice both in 1959 and today? The aswer is a definate "Yes" but only if Basic COBOL, as intended and envisioned by the Committee, is used. Not Broken COBOL.
24 Sat Oct 2009
Admin's Reply:

Jerry Sitner's Comment
Your tutorial COBOL coding example will assure the same non productive Broken Cobol coding that has flooded our COBOL source code since 1959. Your first abbreviation tells the novice programmer it's ok to use abbreviations. That spells the doom for the COBOL productivity promised, intended and envisioned by the Department of Defense Committee that created COBOL 50 years ago. If you care to know how I come to this conclusion I will forward to you any of the 15 articles I have had published over a period of 30 years. These articles have been published in some of the most prestigious publications such as Computerworld, Datamation and, plus others.
24 Sat Oct 2009
Admin's Reply: Jerry, I really liked your comments. Some might see it as negative, I'm not those "some". In between the lines I read that these comment(s) come from someone genuinly a fan of COBOL. I take it as a constructive critism. And I thank you for that. I've worked very hard to make sure that comments such as yours don't get deleted. :) Thanks Again.