COBOL LANGUAGE COmmon Business Oriented Language Sarunya Dechasajja
BACKGROUND -Developed in 1959 by a group of computer professionals called the Conference on Data Systems Languages (CODASYL) -In 1968 the American National Standards Institute (ANSI) developed a standard form of the language. This version was known as American National Standard (ANS) COBOL. -Object-oriented COBOL is a subset of COBOL 97, which is the fourth edition in the continuing evolution of ANSI/ISO standard COBOL. -Like the C++ programming language, object- oriented COBOL compilers are available even as the language moves toward standardization.
DESCRIPTION OF COBOL LANGUAGE -COBOL is a Third-generation programming language, and one of the oldest programming languages still in active use. -Defining its primary domain in business, finance, and administrative system for companies and governments. -Example of COBOL standard: COBOL-68, COBOL- 74, COBOL-85 and COBOL 2002
LANGUAGE PROGRESSIVE
DISTINCTIVE CHARACTERISTIC -The language that automated business -Allows names to be truly connotative - permits both long names (up to 30 characters) and word-connector characters (dashes) -Every variable is defined in detail - this includes number of decimal digits and the location of the implied decimal point -File records are also described with great detail, as are lines to be output to a printer - ideal for printing accounting reports -Offers object, visual programming environments -Class Libraries -Rapid Application Capabilities -Integration with the World Wide Web
DISTINCTIVE CHARACTERISTIC COBOL, long associated with green screens, core dumps, and traditional mainframe connections, may at first glance seem at odds with object technology, push-button graphical interfaces, and interactive development environments. This perceived incongruity, however, is more a reflection of the mainframe’s ability to keep pace with the innovations of desktop and client- server computing than a flaw in the COBOL language.
DESIGN GOALS -One goal of COBOL's design was for it to be readable by managers, so the syntax had very much of an English-like flavor. -The specifications were to a great extent inspired by the FLOW-MATIC language invented by Grace Hopper -She then promoted COBOL’s use
CHARACTERISTICS COBOL is a simple language with a limited scope of function(no pointers, no user defined functions, no user defined types ). And that is the way it used to be but the introduction of OO-COBOL has changed all that. OO-COBOL 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
SAMPLE PROGRAM: Displaying the message "Hello world!" IDENTIFICATION DIVISION PROGRAM-ID. HELLOWORLD * ENVIRONMENT DIVISION CONFIGURATION SECTION SOURCE-COMPUTER. RM-COBOL OBJECT-COMPUTER. RM-COBOL DATA DIVISION FILE SECTION PROCEDURE DIVISION MAIN-LOGIC SECTION BEGIN DISPLAY " " LINE 1 POSITION 1 ERASE EOS DISPLAY "Hello world!" LINE 15 POSITION STOP RUN MAIN-LOGIC-EXIT EXIT. Sample Run Hello world!
SAMPLE PROGRAM: Accepts two numbers and adds them together ID DIVISION PROGRAM-ID. ACCEPT DATA DIVISION WORKING-STORAGE SECTION WS-FIRST-NUMBER PIC 9(3) WS-SECOND-NUMBER PIC 9(3) WS-TOTAL PIC ZZZ * PROCEDURE DIVISION MAINLINE DISPLAY 'ENTER A NUMBER: ' ACCEPT WS-FIRST-NUMBER * DISPLAY 'ANOTHER NUMBER: ' ACCEPT WS-SECOND-NUMBER * COMPUTE WS-TOTAL = WS-FIRST-NUMBER + WS-SECOND-NUMBER DISPLAY 'THE TOTAL IS: ', WS-TOTAL STOP RUN. Sample Run ENTER A NUMBER: a ANOTHER NUMBER: b THE TOTAL IS: a + b
SAMPLE PROGRAM: Takes all input records of salesperson data and writes it to an output file reformatted ID DIVISION PROGRAM-ID. SLS FILE-CONTROL SELECT SALESPERSON-FILE ASSIGN TO DISK SELECT REPORT-FILE ASSIGN TO PRINTER DATA DIVISION FILE SECTION FD SALESPERSON-FILE SALESPERSON-RECORD FILLER PIC XX SP-NUMBER PIC X(4) SP-NAME PIC X(18) FILLER PIC X(21) SP-CURRENT-SALES PIC 9(5)V SP-CURRENT-RETURNS PIC 9(4)V FD REPORT-FILE.
SAMPLE PROGRAM: Takes all input records of salesperson data and writes it to an output file reformatted REPORT-RECORD FILLER PIC X(10) RT-NUMBER PIC X(4) FILLER PIC X(6) RT-NAME PIC X(18) FILLER PIC X(6) RT-CURRENT-SALES PIC ZZ,ZZZ FILLER PIC X(6) RT-CURRENT-RETURNS PIC Z,ZZZ FILLER PIC X(65) WORKING-STORAGE SECTION WS-EOF-FLAG PIC X * PROCEDURE DIVISION * MAIN-ROUTINE OPEN INPUT SALESPERSON-FILE OUTPUT REPORT-FILE MOVE "N" TO WS-EOF-FLAG READ SALESPERSON-FILE AT END MOVE "Y" TO WS-EOF-FLAG END-READ
SAMPLE PROGRAM: Takes all input records of salesperson data and writes it to an output file reformatted * PERFORM UNTIL WS-EOF-FLAG IS EQUAL TO "Y" MOVE SPACES TO REPORT-RECORD MOVE SP-NUMBER TO RT-NUMBER MOVE SP-NAME TO RT-NAME MOVE SP-CURRENT-SALES TO RT-CURRENT-SALES MOVE SP-CURRENT-RETURNS TO RT-CURRENT-RETURNS WRITE REPORT-RECORD READ SALESPERSON-FILE AT END MOVE "Y" TO WS-EOF-FLAG END-READ END-PERFORM * CLOSE SALESPERSON-FILE, REPORT-FILE STOP RUN. Sample Run 0005 BENNETT ROBERT 1, LOCK ANDREW S PARKER JAMES E 18, REDDING OLIVIA 16, , BENTON ALEX J 3, ADAMS JUNE R 4, COLE ROBERT N 14, ,385.29
CONTRIBUTION TO COMPUTER LANGUAGE COBOL programs are in use globally in governmental and military agencies, in commercial enterprises, and on operating systems such as IBM's z/OS, Microsoft's Windows, and the POSIX families
HOW WIDELY USED IS COBOL?? -In 1997 they estimated that there were about 300 billion lines of computer code in use in the world. Of that they estimated that about 80% (240 billion lines) were in COBOL and 20% (60 billion lines) were written in all the other computer languages combined [Brown].Brown -In 1999 they reported that over 50% of all new mission- critical applications were still being done in COBOL and their recent estimates indicate that through % of all new applications (5 billion lines) will be developed in COBOL while 80% of all deployed applications will include extensions to existing legacy (usually COBOL) programs. -Gartner estimates for 2002 are that there are about two million COBOL programmers world-wide compared to about about one million Java programmers and one million C++ programmers.
RESOURCES - /cis400/cobol/cobol.htmlhttp:// /cis400/cobol/cobol.html - command=viewArticleBasic&articleId=266156&pa geNumber=1http:// command=viewArticleBasic&articleId=266156&pa geNumber=1 - m#part1http:// m#part1 Presented by: Sarunya Dechasajja