COBOL
![](http://upload.wikimedia.org/wikipedia/commons/thumb/3/39/Punch-card-blue.jpg/220px-Punch-card-blue.jpg)
Welcome to COBOL at Wikiversity. This area will present information concerning one of the programming languages which, to this day, continues to provide business data processing to the world.
Please forgive the current limited information as the page is built.
"COBOL is widely used in the financial services industry typically for mainframe based applications. It has been used extensively since the 1960s. COBOL was designed for use in business applications and consequently it was implemented with fixed-point arithmetic support. This is one of the advantages of COBOL as it allows complete and accurate computation of financial values without the possibility of rounding errors."[1]
Students with little or no programming experience will benefit by completing the Wikiversity Programming Fundamentals course before beginning this course.
Hello World!
[edit | edit source]It has become customary to start learning a programming language by writing, building, and executing a program that displays "Hello, World!"
Here is a COBOL source code for a Hello World! program, provided by the Wikiversity Hello, world! course:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, World!'.
STOP RUN.
Column Significance
[edit | edit source]When COBOL was originally developed, computer programs were written on 80-column punch cards. The language still contains artifacts of that column orientation. In the punch card era, programs were often written by hand on 80-column coding sheets that corresponded to the 80-columns of each punch card.
Column positions are significant in original implementations of COBOL, and are grouped into the following five fields:[2] Several more modern implementations relax these column requirements.
Positions | Field | Description |
---|---|---|
1-6 | Sequence number area | Reserved for line numbers. |
7 | Indicator area | Used to indicate the type of a source line (i.e. source, comment or continuation). |
8-11 | Area A | Beginning of all divisions, sections, paragraphs and some special entries. |
12-72 | Area B | Beginning of all other statements. |
73-80 | Identification Area | Can be used as needed by the programmer. |
In COBOL 2002, Areas A and B were merged to form the program-text area, which now ends at an implementor-defined column.
The following characters are allowed in the indicator area:
- (space) – Indicates a regular source code line
*
– 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 continuedD
– Line enabled in debugging mode, which is otherwise ignored as a comment
Running the Program
[edit | edit source]The Wikiversity course Programming Fundamentals/Introduction/COBOL provides instructions for compiling and executing this program.
Alternatively, students may wish to use an Integrated Development Environment (IDE) that runs on your computer, rather than the simpler but more limited web-based systems. Although this is more difficult than using the web-based system, it is more flexible, more extensive, and better represents production systems.
To do so, follow these linked instructions for Building and Running a Native IDE.
Assignment
[edit | edit source]Modify the example program to display the phrase "Let's learn COBOL!".
Run and test this modified program.
Language References
[edit | edit source]Because COBOL has continued to evolve since its introduction in 1959 and has been implemented on many different systems, no single document is a definitive language reference. Several useful guides are selected and briefly described here.
- The TutorialsPoint COBOL Quick Guide introduces the fundamentals of the language. Because it is written as a tutorial, it is accessible, but is not a comprehensive or definitive reference.
- The COBOL ANSI-85 Programming Reference is useful because it is a American National Standards Institute standard reference for the language published while COBOL was widely used. It has the advantages of being comprehensive description of a recognized standard, however because of its complexity and scope it is difficult to use as a tutorial.
- The GnuCOBOL Guides are a collection of references for the GnuCOBOL complier. The HTML formatted version is particularly convenient for on-line use. While these are complete and authoritative for the GnuCOBOL compiler, they may not accurately describe other COBOL implementations.
- If you are doing complex work on a production system it is essential that you obtain and use the language reference that pertains specifically to the system you are using.
Language Fundamentals
[edit | edit source]Example programs illustrating COBOL language fundamentals were copied from Programming Fundamentals and are linked here:
Wikibooks
[edit | edit source]See Also
[edit | edit source]References
[edit | edit source]- ↑ QuiteUnusual (13 March 2009). "Software Engineers Handbook/Language Dictionary/COBOL, In: Wikibooks". San Francisco, California: Wikimedia Foundation, Inc. Retrieved 2014-10-18.
- ↑ TutorialsPoint, COBOL, basic syntax https://www.tutorialspoint.com/cobol/cobol_basic_syntax.htm