You are on page 1of 20

Know what the acronym COBOL stands for. Be aware of the significance of COBOL in the marketplace.

Understand some of the reasons for COBOL's success. Be able to understand COBOL Metalanguage syntax diagrams. Be aware of the COBOL coding rules Understand the structure of COBOL programs Understand the purpose of the IDENTIFICATION, ENVIRONMENT, DATA and PROCEDURE divisions.

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).

Common Business Oriented Language (COBOL) is a programming language that resembles English.

COBOL is especially efficient for processing business problems. It emphasizes describing and handling of data items and of input/output records; thus it is well adapted for managing large files of data.

COBOL is non-proprietary (portable): The COBOL standard does not belong to any particular vendor. The vendor independent ANSI COBOL committee legislates formal, nonvendor-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.

There are four divisions in a COBOL program . They are : 1. Identification Division 2. Environment Division 3. Data Division

4. Procedure Division

Identification Division The Identification Division must be the first division in every COBOL source program. It names the program and may include the date the program was written,the date of compilation, and other such documentary information about the program. Code Example: IDENTIFICATION DIVISION. PROGRAM-ID. IDSAMPLE. AUTHOR. PROGRAMMER NAME. INSTALLATION. COBOL DEVELOPMENT CENTER. DATE-WRITTEN. 08/27/88. DATE-COMPILED. 09/01/88 12:57:53. SECURITY. NON-CONFIDENTIAL.

Environment Division The Environment Division has two sections: The Configuration Section The Input-Output Section. The Configuration Section is optional. The Input-Output Section defines each file, identifies its external storage medium,assigns the file to one or more input/output devices, and also specifies information needed for efficient transmission of data between the external medium and the COBOL program.

Code Example:
ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-AS400. OBJECT-COMPUTER. IBM-AS400. SPECIAL-NAMES. C01 IS TOP-OF-PAGE.

Data Division : Sections 1. File Section 2. Working Storage 3. Linkage Section

Linkage section is used only in the called program when parameters are passed programs.

Procedure Division Constructs that can be used in the Procedure Division are : If....else Perform....until Evaluate....when

File commands: READ WRITE REWRITE DELETE

File categories in AS/400 : 1. Database files 2. Device files 3. DDM files 4. Save files

A database file is subdivided into groups of records called members. There are two types of database files: physical files and logical files.

Physical Files: A physical file is a file that actually contains data records. A physical file can contain only fixed-length records, all of which have the same format. Logical Files: A logical file is a database file through which data from one or more physical files can be accessed. The format and organization of this data is different from that of the data in the physical file(s). Device Files : A device file reads from or writes to a device or remote system. A device file controls the transfer of data between the physical device or remote system and the program.

DDM Files : Distributed Data Management (DDM) allows you to access data that reside on remote systems that support DDM. DDM files are supported by the COBOL compiler. You can retrieve, add, update, or delete data records in a file that resides on another system.

Save Files : A save file is a file that is used to prepare data in a format that is correct for backup and recovery purposes or for transportation to another system. A save file can be used to contain the output that is produced from the Save Library (SAVLIB) or Save Object (SAVOBJ) CL commands.

Paragraphs : The Input-Output section of the Environment Division contains two paragraphs: FILE-CONTROL paragraph I-O-CONTROL paragraph. FILE-CONTROL paragraph Names and associates the files with the external media. It must begin in Area A, and be followed by a separator period. I-O CONTROL paragraph Specifies information needed for efficient transmission of data between external media and the COBOL program FILE-CONTROL Paragraph The FILE-CONTROL paragraph associates each file in the COBOL program with an external medium, and specifies file organization, access mode, and other information.

COBOL allows for four distinct kinds of file input and output: Sequential Indexed Relative Data Organization and Access Modes: Data organization is the permanent logical structure of the file. You tell the computer how to retrieve records from the file by specifying the access mode.In COBOL you can specify any of four types of data organization, and three access modes. Data Organization In a COBOL program, data organization can be sequential, indexed, relative, or TRANSACTION. Records can be fixed or variable in length. Access Modes Access mode is a COBOL term that defines the manner in which data in a logical or physical file is to be processed. The three access modes are sequential, random, and dynamic.

The COBOL program (source code ) should be compiled to produce a usable object code. This is done using the CRTCBLPGM command or keying in the option 14 against the source code. The program can be compiled either in batch or interactively.

The most common ways of running a COBOL program are :


1 Using the CL CALL command. 2. Using the COBOL CALL command. 3. Using a menu driven option. 4. issuing a user created command.

Common coding mistakes include :


1. Unmatched record descriptions with externally described files.
2. Missing copy files 3. Misspellings 4. Faulty punctuation especially missing periods 5. Incorrect or incomplete syntax 6. Misuse of reserved words

A subfile is a group of records read from or written to a display device. Subfiles can be specified in the DDS for a display file to allow you to handle multiple records of the same type in a display. Records to be included in the subfile are specified in the DDS for the file One file can contain more than one subfile but only 12subfiles can be active concurrently for a device. That is, 12 subfiles can be displayed on device at the same time. The DDS of a subfile contains 2 record formats, the subfile record format and the subfile control record format. The subfile record format contains the field descriptions for the records in the subfile.

Specifiations of the subfile record format on a READ, WRITE or REWRITE causes the specified subfile record to be processed, but does not affect the displayed data directly. To use a subfile for a display file in a COBOL program , you must specify the SUBFILE phrase with the Input/Output operation. Valid subfile operations are : 1. READ SUBFILE file-name record 2. WRITE SUBFILE record name 3. REWRITE SUBFILE record-name Subfiles are processed sequentially using READ SUBFILE NEXT MODIFIED statement, or processed randomly by specifying a relative key value. A relative key is an unsigned number that can be used directly by the system to locate a record in a file.

You might also like