COBOL

 COmmon Business-Oriented Language

COBOL is a compiled English-like computer programming language designed for business use. It is an imperative, procedural, and, since 2002, object-oriented language. COBOL is primarily used in business, finance, and administrative systems for companies and governments. COBOL is still widely used in applications deployed on mainframe computers, such as large-scale batch and transaction processing jobs. Many large financial institutions were developing new systems in the language as late as 2006, but most programming in COBOL today is purely to maintain existing applications. Programs are being moved to new platforms, rewritten in modern languages, or replaced with other software.

COBOL statements have prose syntax such as MOVE x TO y, which was designed to be self-documenting and highly readable. However, it is verbose and uses over 300 reserved words compared to the succinct and mathematically inspired syntax of other languages.

The COBOL code is split into four divisions (identification, environment, data, and procedure), containing a rigid hierarchy of sections, paragraphs, and sentences. Lacking a large standard library, the standard specifies 43 statements, 87 functions, and just one class.

The height of COBOL's popularity coincided with the era of keypunch machines and punched cards. The program itself was written onto punched cards, then read in and compiled, and the data fed into the program was sometimes on cards as well.

COBOL can be written in two formats: fixed (the default) or free. In fixed-format, code must be aligned to fit in certain areas (a hold-over from using punched cards). Until COBOL 2002, these were:

Name

Column(s)

Usage

Sequence number area

1–6

Originally used for card/line numbers (facilitating mechanical punched card sorting to assure intended program code sequence after manual editing/handling), this area is ignored by the compiler

Indicator area

7

The following characters are allowed here:

  • * – Comment line

  • / – Comment line that will be printed on a new page of a source listing

  • - – Continuation line, where words or literals from the previous line are continued

  • D – Line enabled in debugging mode, which is otherwise ignored

Area A

8–11

This contains: DIVISION, SECTION and procedure headers; 01 and 77 level numbers and file/report descriptors

Area B

12–72

Any other code not allowed in Area A

Program name area

73–80

Historically up to column 80 for punched cards, it is used to identify the program or sequence the card belongs to



I used COBOL professionally in several of my jobs.  First was R/M COBOL on CP/M.  The Service Bureau I worked for sold an accounting package that we did minor customizations for the customers. This is also where I developed the little file clean up utility in assembler.  

The next time was at a University IT Department working on an interactive CICS COBOL utilities that allowed employees to request reprints of their W-2 statements.  It handled collecting and validating the employee information and managing the print queues.  

The last time I had to work with COBOL was the same R/M COBOL Accounting package on SCO Unix on an NCR 68000 Tower.

Sample Code

It took me even longer to remember how to write a COBOL application.  The Microsoft COBOL-80 compiler appears to be ANSI COBOL-74 which does not support free mormatted code.

Here is yet another looped version of the Hello World program.

H>user 1
H>type hello.cob
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLO.
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000410 WORKING-STORAGE SECTION
000420 01  LINECOUNT PIC 99.
000430 01  DISPCOUNT PIC Z9.
000500 PROCEDURE DIVISION.
000600 00-MAIN.
000700     PERFORM SHOW-MESSAGE VARYING LINECOUNT FROM 1 BY 1 
000710         UNTIL LINECOUNT > 10.
000800     STOP RUN.
000900 SHOW-MESSAGE.
000910     MOVE LINECOUNT TO DISPCOUNT.
001000     DISPLAY "Hello World From COBOL, line ", DISPCOUNT.

H>cobol hello,hello=hello/r
Microsoft MS-COBOL
Version 4.65  Copyright 1980,1981,1982 (C) Microsoft

 No Errors or Warnings

H>l80 hello/n,hello/e
Link-80  3.44  09-Dec-81  Copyright (c) 1981 Microsoft

Data    4C00    4F56    <  854>

41731 Bytes Free
[4C44   4F56       79]

H>hello
Hello World From COBOL, Line  1
Hello World From COBOL, Line  2
Hello World From COBOL, Line  3
Hello World From COBOL, Line  4
Hello World From COBOL, Line  5
Hello World From COBOL, Line  6
Hello World From COBOL, Line  7
Hello World From COBOL, Line  8
Hello World From COBOL, Line  9
Hello World From COBOL, Line 10

H>

References

This article uses material from the Wikipedia article COBOL which is released under the Creative Commons Attribution-Share-Alike License 4.0.

Comments

Popular posts from this blog

Still Working on the New Home Page

A New Home Page is in the works!

Old Quizzes that have been taken down