| 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 commercial data processing. 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. Do COBOL Programs have paragraphs like in English? |
| A COBOL Program consists of 4 main divisions : IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION and PROCEDURE DIVISION. IDENTIFICATION DIVISION is used to identify the COBOL Program to the system. It tells the system, what’s the name of the program, who has written it, when the COBOL Program was written, when it was compiled etc. ENVIRONMENT DIVISION tells the system, about the environment, the computer equipment used to run the COBOL Program. It gives information about the input and output file-names used in the COBOL Program. DATA DIVISION declares any input-output areas and temporary work-areas of the program. PROCEDURE DIVISION is the starting point of the COBOL Program, where you will code the real COBOL instructions. |
| Q. Show me the basic skeleton of a COBOL Program then.. |
| The basic skeleton of a COBOL Program is as follows : IDENTIFICATION DIVISION. |
| Q. Paragraphs in the English language are indented. Do you have indentation/alignment rules in COBOL? |
| Just like paragraphs in English, COBOL Divisions and Paragraphs must follow strict alignment rules. The way we indent paragraphs in English, you must indent different Divisions, sections and paragraphs in a COBOL Program. When you write COBOL on the mainframe terminal, or on a coding sheet, the lines are divided into 80 columns. The column 8 is called column A. Column 12 is called column B. The area spanning from columns 8-11 is called Area A. The area spanning from columns 12-72 is called Area B. All division, section, paragraph names, FD entries and 01-level entries must start in Area A. This means they must start from any column 8,9,10 or 11. The rest of the sentences should start from Area B. All division and section names must begin on a separate line. There should be atleast one space between paragraph name and its sentences. Column 7 is used as a special indicator. If you want to write COBOL comments to explain the meaning of a Line of Code in COBOL, you must put an asterisk (*) in the column 7. |
| 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
|
|
|
- Re-writing of select JCL and VSAM Tutorials is under-way, orientation would be more hands-on, and practical - New Tutorials on COBOL-VSAM programs shall be put up pretty soon - IMS DB/DC Tutorials to start up in April, 2010 |
Thursday, August 6, 2009
COBOL Tutorial – Introduction, Writing a Simple Hello World COBOL Program
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