0% found this document useful (0 votes)
74 views

What Is Cobol?

COBOL was created in 1959 to develop a common business-oriented programming language that could be used across different computer systems. It was designed to be English-like, machine independent, and easy for non-technical users to understand. COBOL emphasizes manipulating and processing large files of business data in a simple way. It has become one of the most widely used programming languages for business applications.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

What Is Cobol?

COBOL was created in 1959 to develop a common business-oriented programming language that could be used across different computer systems. It was designed to be English-like, machine independent, and easy for non-technical users to understand. COBOL emphasizes manipulating and processing large files of business data in a simple way. It has become one of the most widely used programming languages for business applications.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

WHAT IS COBOL? In 1959 it was decided that it would be desirable to produce a common programming language for business applications.

Until 1959 each computer had its own specific language which was either numeric or machine code. The benefits of this common language would be: 1. It would be machine independent and thus transfer of programs between machines would be easier. 2. The language would be in English narrative form. 3. Relatively inexperienced personnel could write programs. 4. Training of personnel could be speeded up. 5. The language should be designed so that new facilities can be added when necessary. From the above aims COBOL was designed ; COBOL stands for COmmon Business Oriented Language ( or COmmercial Business Oriented Language in some texts). The language emphasises the description and handling of data items and of input/output records. Instead of extensive algebraic or logical processing, COBOL applications manipulate large files of data in a relatively simple way. Today COBOL is available on a large range of machines. It is produced to American National Standards Institute (ANSI) specifications. The benefit of the standard is that the same COBOL instructions work in the same way on every machine. COBOL is an English based language that can be self-documenting. Like any language it has its own grammar or syntax rules which must be adhered to. It is part of the COBOL syntax that instructions are written in the correct place and throughout this course column positions will be given. The general rule is one COBOL statement per line but the exact layout of statements will be described (where applicable) later in the course. The current version of COBOL is COBOL 85. It got that name from the year in which the standard was adopted. The marketing name for COBOL 85 is

COBOL II. Before this version everyone was using COBOL 74 but calling it COBOL or OS/VS COBOL (on the mainframe). COBOL II is a licensed program that prepares COBOL programs for execution in an IBM processor. COBOL II extends many of the capabilities of any previous COBOL product, allowing for improved programmer productivity, application efficiency, debugging and maintenance. To coincide with the implementation of COBOL II, Norwich Union introduced a revised set of COBOL Programming Standards. These standards apply to all COBOL code that should be written in COBOL II (on the mainframe) or COBOL/2 (on the PC). The purpose of the standards is to ensure that all COBOL programs written within NU are a consistent style. By adhering to the standards, programmers will ensure that their programs are written and maintained in the most efficient way

FUNCTIONS OF COBOL COBOL functions offer a new way to manipulate data that was not available in older versions. We will look at a series of COBOL functions in this handout. Functions are available for: mathematics, character manipulation, date/time and statistics and financial work. They can be used throughout the Procedure Division. Functions are elementary data items that will return a numeric (whole or decimal) or an alphanumeric. A function cannot be used as a receiving operand. When using a function, you must always use the word FUNCTION followed by the specific function you are using following by any required or optional arguments. Function definitions are described in alphabetical order in the following sections. ACOS - returns a numeric value, expressed in radians, that approximates the arccosine of argument-1. The type of this function is floating point. ANNUITY- (annuity immediate) returns a numeric value that approximates the ratio of an annuity paid at the end of each period for the number of periods

specified by argument-2 to an initial investment of one. Interest is earned at the rate specified by argument-1 and is applied at the end of the period, before the payment. The type of this function is floating point. ASIN- returns a numeric value, expressed in radians, that approximates the arcsine of argument -1. The type of this function is floating point. ATAN - returns a numeric value, expressed in radians, that approximates the arctangent of argument-1. The type of this function is floating point. CHAR - returns a 1-character alphanumeric value that is a character in the program collating sequence having the ordinal position equal to the value of argument-1. The type of this function is alphanumeric. COS - T returns a numeric value that approximates the cosine of an angle or arc, expressed in radians, that is specified by argument-1. The type of this function is floating point. CURRENT-DATE - returns a 21-character alphanumeric value that represents the calendar date, time of day, and local time differential factor provided by the system on which the function is evaluated. The type of this function is alphanumeric. DATE-OF-INTEGER - converts a date in the Gregorian calendar from integer date form to standard date form (YYYYMMDD). The type of this function is integer. DAY-OF-INTEGER - converts a date in the Gregorian calendar from integer date form to Julian date form (YYYYDDD). The type of this function is integer. FACTORIAL - returns an integer that is the factorial of argument-1. The type of this function is integer. INTEGER - returns the greatest integer value that is less than or equal to the argument. The type of this function is integer. INTEGER-OF-DATE - converts a date in the Gregorian calendar from standard date form (YYYYMMDD) to integer date form. The type of this function is integer. INTEGER-OF-DAY - converts a date in the Gregorian calendar from Julian date form (YYYYDDD) to integer date form. The type of this function is integer.

INTEGER-PART - returns an integer that is the integer portion of argument-1. The type of this function is integer. LENGTH - returns an integer equal to the length of the argument in character positions. The type of this function is integer. LOG - returns a numeric value that approximates the logarithm to the base a (natural log) of argument-1. The type of this function is floating point. LOG10 - returns a numeric value that approximates the logarithm to the base 10 of argument-1. The type of this function is floating point. LOWER-CASE - returns a character string that is the same length as argument-1 with each uppercase letter replaced by the corresponding lowercase letter. The type of this function is alphanumeric. MAX - returns the content of the argument-1 that contains the maximum value. The type of this function depends upon the argument types as follows: Argument Type Alphabetic Alphanumeric All arguments integer Numeric (some arguments can be integer) MEAN - returns a numeric value that is the arithmetic mean (average) of its arguments. The type of this function is numeric. MEDIAN - returns the content of the argument whose value is the middle value in the list formed by arranging the arguments in sorted order. The type of this function is numeric. MIDRANGE - returns a numeric value that is the arithmetic mean (average) of the values of the minimum argument and the maximum argument. The type of this function is numeric. MIN - returns the content of the argument-1 that contains the minimum value. The type of this function depends upon the argument types as follows: Argument Type Alphabetic Function Type Alphanumeric Function Type Alphanumeric Alphanumeric Integer Numeric

Alphanumeric All arguments integer Numeric (some arguments can be integer)

Alphanumeric Integer Numeric

MOD - returns an integer value that is argument-1 modulo argument-2. The type of this function is integer. NUMVAL - returns the numeric value represented by the character string specified by argument-1. Leading and trailing spaces are ignored. The type of this function is floating point. NUMVAL-C - returns the numeric value represented by the character string specified by argument-1. Any optional currency sign specified by argument-2 and any optional commas preceding the decimal point are ignored. The type of this function is floating point. ORD - returns an integer value that is the ordinal position of argument-1 in the collating sequence for the program. The lowest ordinal position is 1. The type of this function is integer. ORD-MAX - returns a value that is the ordinal number of the argument-1 that contains the maximum value. The type of this function is integer. ORD-MIN - returns a value that is the ordinal number of the argument that contains the minimum value. The type of this function is integer. PRESENT-VALUE - returns a value that approximates the present value of a series of future period-end amounts specified by argument-2 at a discount rate specified by argument-1. The type of this function is floating point. RANDOM - returns a numeric value that is a pseudo-random number from a rectangular distribution. The type of this function is numeric. RANGE - returns a value that is equal to the value of the maximum argument minus the value of the minimum argument. The type of this function depends upon the argument types as follows: Argument Type All arguments integer Numeric Function Type Integer Numeric

(some arguments can be integer) REM - returns a numeric value that is the remainder of argument-1 divided by argument-2. The type of this function is numeric. REVERSE - returns a character string of exactly the same length as argument-1 and whose characters are exactly the same as those of argument-1, except that they are in reverse order. The type of this function is alphanumeric. SIN - returns a numeric value that approximates the sine of an angle or arc, expressed in radians, that is specified by argument-1. The type of this function is floating point. SQRT - returns a numeric value that approximates the square root of argument1. The type of this function is floating point. STANDARD-DEVIATION - returns a numeric value that approximates the standard deviation of its arguments. The type of this function is numeric. SUM - returns a value that is the sum of the arguments. The type of this function depends upon the argument types as follows: Argument Type All arguments integer Numeric (some arguments can be integer) TAN - returns a numeric value that approximates the tangent of an angle or arc, expressed in radians, that is specified by argument-1. The type of this function is floating point. UPPER-CASE - returns a character string that is the same length as argument-1 with each lowercase letter replaced by the corresponding uppercase letter. The type of this function is alphanumeric. VARIANCE - returns a numeric value that approximates the variance of its arguments. The type of this function is numeric. WHEN-COMPILED - returns the date and time the program was compiled as provided by the system on which the program was compiled. The type of this function is alphanumeric. Function Type Integer Numeric

COMMANDS OF COBOL ACCEPT Statement - takes data from a device and puts it into a data item. ADD Statement - forms the sum of two or more operands and stores the result. ALTER Statement - modifies a predetermined sequence of operations. This statement has the potential for causing great harm in the form of obscure program errors, and its use is not recommended. In addition, it is an obsolete element and is slated for deletion from the next revision of the Standard. BEGIN Statement - indicates the start of a transaction or subtransaction. CALL Statement - invokes another program in the run unit. CANCEL Statement - ensures that a program is in its initial state the next time it is called. CLOSE Statement - terminates the processing of reels and files with optional rewinding and/or locking. Note that the operating system attempts to close any open files when a STOP RUN statement is executed COMMIT Statement - commits a transaction or subtransaction by writing its associated updates to disk and releases resources held by the program. COMPUTE Statement - evaluates an arithmetic expression and sets one or more data items equal to the result. CONTINUE Statement - is a no operation statement. The CONTINUE statement can be used anywhere a conditional statement or an imperative statement can. DELETE Statement - removes a record from a relative or indexed file. DISPLAY Statement - transfers data to a workstation. DISPLAY AND READ Statement - controls data displayed on and read from the workstation. DIVIDE Statement - divides one item into another and sets one or more data items equal to the quotient and another data item equal to the remainder. ENTER Statement - is treated as a comment. EVALUATE Statement - defines a multibranch, multijoin structure. Multiple conditions can be tested and different branches executed based on the results of these tests. EXIT Statement - provides a common end point for a series of procedures.

EXIT PROGRAM Statement - marks the logical end of a called program. FREE ALL Statement - commits all uncommitted transactions and subtransactions and frees held resources. Refer to the section titled "COMMIT Statement" earlier in this chapter for details. GO TO Statement - transfers control to a paragraph or section. HOLD Statement - reserves a file or a range of records in a file or reserves the exclusive right to claim these resources. IF Statement - evaluates a condition and takes subsequent action based on the truth value of that condition. INITIALIZE Statement - assigns values to data items. This provides a way of initializing file items that cannot have a VALUE IS clause. INSPECT Statement - counts and/or replaces single characters or groups of characters in a data item. MERGE Statement - combines two or more ordered files based on the values of one or more keys. During this process, the records in the files being merged are made available, in merged order, to a file or an output procedure: MOVE Statement - transfers data to one or more data items. MULTIPLY Statement - multiplies two items and sets one or more data items equal to the result. OPEN Statement - makes a file available to the program. PERFORM Statement - transfers control to a procedure and gets control back when the procedure has been completed It also can execute one or more statements written within the PERFORM statement itself. READ Statement - makes a record of a file available to the program. RELEASE Statement - transfers records to the initial phase of a sort operation. RETURN Statement - obtains sorted records from the final phase of a sort operation or merged records from a merge operation. REWRITE Statement - replaces an existing record. ROLLBACK Statement - removes all updates and releases all locks acquired since the corresponding BEGIN statement.

SET Statement - assigns or modifies an index data item or index, assigns a status to a mnemonic name, sets a condition name true, or sets a figurative constant to a value. SORT Statement - creates a sort file either by executing an input procedure or by transferring records from another file. It then sorts the records by one or more keys and makes each record available, in sorted order, to an output procedure or file. STOP Statement - temporarily or permanently suspends program execution. The STOP literal-1 form of this statement is an obsolete element, scheduled to be deleted from the next revision of Standard COBOL. STRING Statement - concatenates (that is, strings) two or more data items, in whole or in part, into a single data item. SUBTRACT Statement - subtracts one item or the sum of two or more items from one or more items and sets one or more items equal to the result. UNSTRING Statement - moves data from a single field to multiple fields. USE Statement - specifies input-output error-handling procedures that are executed in addition to the standard procedures provided by the file system.

DIFFERENTIATE COBOL FROM C++ COBOL as define earlier is a first widely-used high-level programming language for business applications while C++ was designed to serve as an enhanced version of the C programming language and it is considered a high level language but low level facilities. C++ is also use in computer programming.C++ introduced the use of declarations as statements and includes more type checking while in COBOL has an effort to make a programming language that was like natural English, easy to write and easier to read the code after you'd written it. The commands and functions of the two are diverse.

PRINCIPLE OF FILE ORGANIZATION CSC 132

Submitted to: Prof. Charito Molina

Submitted by: Fairlyn C. Matibag

You might also like