| Q. What does COBOL stand for? What are the application areas where COBOL Programs written? |
| COBOL stands for Common Business Oriented Language. COBOL Programs are used for processing business data. COBOL is an English-like language. Writing a COBOL program is just like writing a passage in English. |
| Q. You said COBOL Programming language bears resemblance with English. How’s that? |
| Just as text in English is organised into sections and para’s, COBOL Programs can also be broken down into divisions, divisions further into sections, and sections into paragraphs. Each paragraph contain sentences, or COBOL Statements. Like the English language, sentences(statements) in COBOL should end with a period(full-stop). When you start new paragraphs in COBOL, you need to indent them, just as in English you follow indentation rules. COBOL then is whole-lot English like. Even instructions in COBOL, are words borrowed from English, ADD, SUBTRACT, MULTIPLY, DIVIDE etc. |
| Q. What’s the basic skeleton of a COBOL Program |
| The basic skeleton of a COBOL Program is as follows : A COBOL Program can be divided or broken down into 4 parts – IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION and PROCEDURE DIVISION. The PROCEDURE DIVISION contains the instructions to be executed(performed), one after the other, step-by-step till you reach the end of the Program and stop running it(STOP RUN). However , to better organize a COBOL Program, under a division, you may have several sections as well, and sections in turn can have several paragraphs. Divisions, sections and paragraphs help make the COBOL Program more structured, and the flow of the COBOL Program is easy to grasp. |
| Q. What are the Alignment(Indentation rules) in COBOL? |
| The lines in a COBOL Program are indented or aligned, as its done in English. When you write COBOL Program on the Mainframe terminal, you have 80 columns on a line to code on. The area spanning from columns 8-11 is called Area A. The area spanning from columns 12-72 is called Area B. In COBOL, division names, sections and paragraphs begin in Area A. See below, how I’ve coded IDENTIFICATION DIVISION, ENVIRONMENT DIVISION,.. etc. starting on Column 8 - You code COBOL Instructions, COBOL Statements in Area B(that’s anywhere between Column 12 – 72). So, all your COBOL Instructions in the PROCEDURE DIVISION like ADD, SUBTRACT, MOVE should begin on or after Column 12. Look below, how I’ve coded COBOL Instructions in Area B. |
| Q. What is the IDENTIFICATION DIVISION used for? |
| The IDENTIFICATION DIVISION is used to identify the COBOL Program to the system. It has the following paragraphs : PROGRAM-ID. The PROGRAM-ID gives the identity or name of the COBOL Program. The INSTALLATION would be the name of the company.DATE-WRITTEN gives the date when the COBOL Program is written. DATE-COMPILED gives the date when the COBOL Program was compiled. SECURITY gives the level of security. Remember, that only the PROGRAM-ID paragraph is mandatory, all the other entries are optional. |
| Q. What does the PROCEDURE DIVISION look like? What’s the format/syntax. Can you elaborate.. |
| The PROCEDURE DIVISION indicates the entry-point or starting point of the COBOL Program. This is where the computer system begins to run(execute the COBOL instructions). Hence, all your instructions/programming logic must be written inside this PROCEDURE DIVISION. I will now show you a simple Hello World Program in COBOL to illustrate the process of writing a COBOL Program, compiling it, linking it and running the program. In the COBOL Program, we want display output, or print some text. When we want to display output, or print text, we use the DISPLAY instruction/verb. The syntax of DISPLAY is as follows : DISPLAY text The text must be enclosed in single quotes. For example, to print Hello World, we must write the instruction : DISPLAY ‘HELLO WORLD’. The PROCEDURE DIVISION of a COBOL Program can have many instructions. We can also divide these instructions into small groups/paragraphs. Thus, the PROCEDURE DIVISION has the following format - PROCEDURE DIVISION. Every COBOL Program has a statement/instruction STOP RUN. The STOP RUN instruction tells the mainframe system, that this is the end of the COBOL Program. So, STOP RUN is the point in the COBOL Program, where program execution stops/halts – the control exits out of the COBOL Program. Given below is a simple Program that prints HELLO WORLD to the Output. |
| Q. How do you compile a COBOL Program? What is meant by Linking a COBOL Program? Finally, how do you run the Program on a Mainframe System? |
| |
Bulletin Board
|
|
|
- I am writing articles on CICS. The effort would be to make the material of certain standard, practical and easy to comprehend. - JCL needs fresh look, and more weightage needs to assigned to conventions and practises adopted in Production Environments at most sites - A note of appreciation : Thanks to all our followers, for making Mainframes360 a success! |
Thursday, August 6, 2009
Introduction to COBOL Programming
Subscribe to:
Post Comments (Atom)
Note :
| © Copyright – Quasar Chunawalla, 2010.
Note : The copyrights of all the material, text and pictures posted in this website belong to the author. Any instance of lifting the material from this website, shall be considered as an act of plagiarism. For any clarifications, please mail at quasar.chunawalla@gmail.com |

2 comments:
Good overview for mainframe environment. For another example of "Hello World" COBOL demo program which students can download,compile, and execute on Windows or Linux in 4 different target platform languages at no cost, try zcobol which can be downloaded as open source included with z390 from www.z390.org. The COBOL demo can be compiled into executable mainframe HLASM compatible assembler, MS Visual Express C, J2SE Java, or Intel MASM compatible assembler. the zcobol compiler consists of a J2SE java regular expression parser and translator to HLASM macro source code which is then compiled into the target language using structured conditional macro code. For more on zcobol and current progress in passing all the NIST COBOL 1985 standard test program suite of 415 programs visit www.zcobol.org.
can u pls help me with the explain with any real time project which make me understand better for the interviews,,,,
Post a Comment