Académique Documents
Professionnel Documents
Culture Documents
Introduction to COBOL
COBOL is a high-level programming language first developed by the CODASYL Committee (Conference on Data Systems Languages) in 1960. Since then, responsibility for developing new COBOL standards has been assumed by the American National Standards Institute (ANSI). Three ANSI standards for COBOL have been produced: in 1968, 1974 and 1985. A new COBOL standard introducing object-oriented programming to COBOL is due within the next few years. The word COBOL is an acronym that stands for COmmon Business Oriented Language. As the expanded acronym indicates, COBOL is designed for developing business, typically fileoriented, applications. It is not designed for writing systems programs. For instance you would not develop an operating system or a compiler using COBOL.
History of COBOL
The first COBOL compiler became available in early 1962. The next version with some new additions was published in 1965. In August 1968 a standard version of the language was approved by the American National Standard Institute (ANSI). This standard version was again modified in 1974 and is known as ANSI-74 COBOL or COBOL -74. The revision process has been continuous and in 1985 a revised standard was introduced. This standard was known as COBOL-85.
Characteristics of COBOL
COBOL is self-documenting One of the design goals for COBOL was to make it possible for non-programmers such as supervisors, managers and users, to read and understand COBOL code. As a result, COBOL contains such English-like structural elements as verbs, clauses, sentences, sections and divisions. It has made COBOL the most readable, understandable and self-documenting programming language in use today. It has also made it the most verbose. It is easy for programmers unused to the business programming paradigm, where programming with a view to ease of maintenance is very important, to dismiss the advantage that COBOL's readability imparts. Not only does this readability generally assist the maintenance process but the older a program gets the more valuable this readability becomes. COBOL is simple
COBOL is a simple language (no pointers, no user defined functions, no user defined types) with a limited scope of function. It encourages a simple straightforward programming style. Curiously enough though, despite its limitations, COBOL has proven itself to be well suited to its targeted problem domain (business computing). Most COBOL programs operate in a domain where the program complexity lies in the business rules that have to be encoded rather than in the sophistication of the data structures or algorithms required. And in cases where sophisticated algorithms are required COBOL usually meets the need with an appropriate verb such as the SORT and the SEARCH. We noted above that COBOL is a simple language with a limited scope of function. And that is the way it used to be but the introduction of OO-COBOL has changed all that. OOCOBOL retains all the advantages of previous versions but now includes
User Defined Functions Object Orientation National Characters - Unicode Multiple Currency Symbols Cultural Adaptability (Locales) Dynamic Memory Allocation (pointers) Data Validation Using New VALIDATE Verb Binary and Floating Point Data Types User Defined Data Types
COBOL is non-proprietary (portable) The COBOL standard does not belong to any particular vendor. The vendor independent ANSI COBOL committee legislates formal, non-vendor-specific syntax and semantic language standards. COBOL has been ported to virtually every hardware platform - from every favour of Windows, to every falser of Unix, to AS/400, VSE, OS/2, DOS, VMS, Unisys, DG, VM, and MVS.
COBOL is Maintainable COBOL has a 30 year proven track record for application maintenance, enhancement and production support at the enterprise level. Early indications from the year 2000 problem are that COBOL applications were actually cheaper to fix than applications written in more recent languages. One reason for the maintainability of COBOL programs has been given above - the readability of COBOL code. Another reason is COBOL's rigid hierarchical structure. In COBOL programs all external references, such as to devices, files, command sequences, collating sequences, the currency symbol and the decimal point symbol, are defined in the Environment Division. When a COBOL program is moved to a new machine, or has new peripheral devices attached, or is required to work in a different country; COBOL programmers know that the parts of the program that will have to be altered to accommodate these changes will be isolated in the Environment Division. In other programming languages, programmer discipline could have ensured that the references liable to change were restricted to one part
2
of the program but they could just as easily be spread throughout the program. In COBOL programs, programmers have no choice. COBOL's rigid hierarchical structure ensures that these items are restricted to the Environment Division.
CHARACTER SET
To learn any language, first one must know the alphabets of the language and they are known as character set in general. There are 50 diff rent characters in COBOL character set. They are listed below: 0-9 A-Z + * / := $ , ; . 10 numerals 26 English alphabets-only capital letters minus sign or hyphen Plus sign Asterisk Slash Equal sign Currency sign Comma Semi colon Period or decimal point
( ) > <
Quotation mark Left Parenthesis Right Parenthesis Greater than symbol Less than symbol
The characters 0-9 are called numeric characters o r digits. The characters A-Z are called letters and the remaining characters are called special characters. The space or blank character in certain cases is treated as a letter.
COBOL WORDS
A COBOL word can be formed using the following characters: 0-9 A-Z (a-z) - (hyphen) The following rules must be adhered in forming COBOL words. (i) A word cannot begin or end with a hyphen. (ii) A word can have at the maximum 30 characters. (iii) One of the characters must be a letter. Some compilers put the additional restrictions that the first character must be a letter. (iv)Except hyphen (-) no special character allowed.
LITERALS
The actual values can also appear in a program. Such values are known as literals. For Example, the statement MOVE 0 TO TOTAL indicates that the value zero will be moved to the variable TOTAL. This constant 0 which used in the body of the statement is a literal. A data name may have different values at different points of time whereas a literal means the specific value which remains unchanged throughout the execution of the program.
For this reason a literal is often called a constant. Moreover the literal is not given a name; it represents itself and does not require to be defined in the DATA DIVISION. There are 3 types of literals: a) numeric b) nonnumeric. c) figurative constants (a) Numeric A numeric literal can be formed with the help of digits only. It can have a sign (+ or -) and can have a decimal point also. If no sign is specified the literal will be taken as positive. Negative literals are indicated by sign at the leftmost end. If no decimal point is used then the literal is obviously an Integer. If a decimal point is used, it must come in between the digits. The maximum number of digits allowed in a numeric literal is compiler dependent. (b) Nonnumeric A nonnumeric literal is used in general to output messages or headings. Characters that are enclosed between constitute nonnumeric literal. The maximum number of characters that are allowed within two quotation marks is compiler dependent.
c) Figurative Constants
Figurative constants have some fixed names and the compiler recognizes these names and it sets up corresponding values in the object program. Consider the statement given below: MOVE ZERO TO COUNTER Here value 0 will be moved to COUNTER by the compiler, as it recognizes ZERO and sets COUNTER with 0.
OUTPUT:
OUTPUT:
10
11
OUTPUT:
12
13
OUTPUT:
14