Monday, November 17, 2014

Introduction to COBOL Programming language

HISTORY OF COBOL
          In 1959, the new language named COBOL (Common Business Oriented Language) was introduced keeping in mind the business purpose applications. The first COBOL compiler became available in early 1962. COBOL is a high-level language. Hence, a COBOL program can be executed on a computer for which a COBOL compiler is available. The compiler translates a COBOL source program into the machine language object program. This object program is really executed. COBOL programs are written in coding sheets. There are 80 columns in a line of the coding sheet. The page number is coded in columns 1-3 and the line numbers are coded in columns 4-6. The page and line numbers together is called the sequence number. Depending on the type, the entries are coded both from column 8 or column 12 and in both cases it can be continued up to column 72. Columns 73-80 can be used to write some identification. The compiler ignores anything that is given in columns 73-80 except when a printed copy of the program is provided by the compiler in which case the entries in columns 73-80 are also listed. The use of the sequence number is also optional and can be omitted. However, when sequence numbers are provided they must appear in ascending order.
Column                                     Field
1-3                          Page Number
4-6                         Line Number (1-6 Sequence Number)
7                             Continuation / Comment
8-11                        A – Margin / Area A
12-72                      B- Margin /Area B
73-80                      Identification

               In COBOL there are two types of entries known as margin A and margin B entries. Margin A entries start from column 8, 9, 10 or 11 and margin B entries start from column 12 or anywhere after 12. An asterisk (*) in column 7 indicates a comment line and the entry is not compiled to produce object code. Comment lines are actually some notes revealing the intentions of the programmer. Since the compiler ignores them, anything can be included as comments. Comment lines can appear anywhere after the first line of the COBOL program. A comment line can also be indicated by using the character slash ( / ) in column 7. But in this case the comment line will be printed after causing a page ejection (i.e., after skipping to the top of the next page).
STRUCTURE OF A COBOL PROGRAM
                    Every COBOL program must have the following 4 divisions in the order in which they are specified below.
  • Identification division
  • Environment Division
  • Data Division
  • Procedure Division
  The Identification division the details about the author, date of writing the program etc will be specified.
In the Environment division, the details about the computer environment under which the program was written and compiled etc will be notified.
In the Data division, the variables that are used by the program will be defined and it is an important division for the program.
The procedure division, all the programming statements (Executable Cobol statements) will be written and it is the most important division.
Under the divisions there are various sections intended for specific purposes. To name a few, working-storage section and File section come under Data division. Their purpose will be to allocate memory space for the variables and to notify the files that are to be used with the program.
A statement of a COBOL program can be written in one or more coding lines. To continue in the next line one has to use a hyphen (-) in column 7.

2 comments:

  1. how do we download the Cobol application to start writing programs?

    ReplyDelete
  2. You must have a COBOL Complier on your system before you can start coding in COBOL Programming language. COBOL Compliers can be downloaded on the internet. In fact there are thousands of COBOL Compliers of download on the net,it just depends on your choice.

    You can check http://www.winsite.com/cobol/cobol+compiler/ for a list of COBOL Compliers you can download

    ReplyDelete