Jump to content
xisto Community
vicky99

An Introduction To COBOL

Recommended Posts

Dear FriendsA few days back I was looking for a COBOL compiler. Therefore I made a post here assuming that some might come to my rescue. A few help did come but wasn’t very satisfying. Eventually I found the compiler I was looking for. My compiler is Micro Focus COBOL COMPILER 2.4.12. It runs smoothly under Windows 98, Windows XP and Windows 2003 (I have personally tested it on these operating systems). When I turned to this forum for help regarding COBOL I was surprised to see that there was not even one topic written about COBOL. So I decided to write something about COBOL (though I have been learning COBOL for merely two three days).COBOL is a programming language designed for solving business problems. COBOL though solves a lot more than just business problems and can be used as a solution to many data processing problems. COBOL excels in accounting systems and related activities such as inventory control, retail sales tracking, contact management, commissions, payroll etc etc. It is like English and easy to read. This is why people with little programming knowledge tend to favor it. COBOL professionals got a real boost when Y2K problem surfaced. In old COBOL dealing with date math is even more complicated. Dates in COBOL are typically stored in three different locations (a month, a day, and a year). The year is often stored as 2 digits to save space and simplify output problems with pre-printed forms. In some cases, COBOL programs were written with 4 digit dates and 1900 is subtracted from the date to generate the form (1981 - 1900 = 81) so that the form can look like 1981 when it is generated. This will cause a problem since 2001 - 1900 = 101 instead of 01. In other cases where a 6 digit date was used, the problem is even worse since there is no clear indication of which date we are talking with. Imagine COBOL program that deals with county records to record births and deaths. If all the dates are stored as 6 digits soon you will have records which say something like 08/04/54. Let us suppose, a man live to be a hundred years old, his date of birth is recorded as 08/04/54 and if he dies on his birthday 100 years later his death would also be 08/04/54. A casual observer might interpret this as him dying at birth or who knows what. The situation is not limited to COBOL programs, but because COBOL has been the language of fondness for business applications for so long, there are vastly more COBOL programs in existence. The importance of the year 2000 catastrophe has caused knowledgeable software experts to forecast horrible consequences. It is estimated that the cost of fixing the crisis will run into the billions of dollars. The demand for COBOL programmers increases more or less weekly, as more and more companies understand the scope of the year 2000 problem and begin to apportion resources for its solution.COBOL stands for Common Business Oriented Language. COBOL was developed by the Conference on Data Systems Languages (CODASYL), convened in 1959 by the Department of Defense. COBOL compilers were available in 1960. The American National Standards Institute (ANSI) standardized a version of COBOL in 1968. The language was revised and updated by ANSI in 1974 and again in 1985. These standards sometimes are called COBOL or COBOL-68, COBOL-74, or COBOL-85. Most compilers are now COBOL-85 standard.Some of the advantages of COBOL are that it caters well for business needs and is easily portable to different operating systems or platforms. However, the language is considered to be rather wordy with an overly rigid format. A further disadvantage is that COBOL lacks many of the programming instructions required by the scientific community.Let’s write our first COBOL program. As you might have started learning many languages by printing “HELLO WORLD” in the screen, this is no exception. We shall write a program which would print “HELLO WORLD”.Type the following codes in any text editor, say for example NOTEPAD.000100 IDENTIFICATION DIVISION.000200 PROGRAM-ID. HELLO.000300 ENVIRONMENT DIVISION.000400 DATA DIVISION.000500 PROCEDURE DIVISION.000600000700 PROGRAM-BEGIN.000800 DISPLAY "HELLO WORLD".000900001000 PROGRAM-DONE.001100 STOP RUN.Save the file. Name the file HELLO.COB. Select “ALLFILES” in Save as type Field. I am assuming that you have Micro Focus Compiler, though the process is similar in all compilers. Create the Directory Called cob1 in C Drive (As I have done) and place the hello.cob file in that directory.Now run the COBOL compiler. It is usually done by changing directory.C:\>cd cobolC:\Cobol>Now give COBOL command and as the following.C:\Cobol>cobol Microsoft COBOL CompilerVersion 2.20 ©Copyright Microsoft Corp. 1982-87Source filename [.COB]: c:\cob1\hello.cobObject filename [HELLO.INT]: c:\cob1\hello.intListing filename [NUL.LST]: c:\cob1\hello.lst** Scanning Environment Division...** Scanning Data Division...** Compiling Procedure Division...** Generating Object Code... No errors or warnings Data area size = 232 Code area size = 38-------------------------------------------------------------------------------------------------------Now Run the program using “runcob” commandC:\Cobol>runcob c:\cob1\helloIt will produce the following outputHELLO WORLD.I hope you would like this article. If anybody is interested to learn COBOL please write to me and if some one is an expert please do help me in learning COBOL. Thank you all for your time. Bye..

Share this post


Link to post
Share on other sites

I learnt COBOL in an institute about 8 years ago when I was in the 9th standard :unsure:. Back then I was pretty good at it, but now I hardly remember anything about it at all. But, is there any application for COBOL now? I mean this generation of programming languages are obsolete now. You can code more easily and efficiently in C or C++. Besides, the formatting for COBOL is so rigid that it takes quite a while to debug big programs.

Share this post


Link to post
Share on other sites

My compiler is Micro Focus COBOL COMPILER 2.4.12.

Your first question seemed to be about a free Cobol compiler.Micro-Focus is the king of Cobol compilers (until being bought by Merant) but I don't think that their compiler is free. Is it ?

Share this post


Link to post
Share on other sites

Yes, you are absolutely right. It’s not at all free. A friend of mine gave me this compiler and I can tell you it a very good one. I would like everybody with knowledge of COBOL to contribute here and I would like to request the moderators to open a new forum for COBOL like there are for other programming language. COBOL might not have any role in today’s world but it was a very effective tool and it will help young ones to know about a very good programming language. Bye.

Share this post


Link to post
Share on other sites

But, is there any application for COBOL now?

Of course, most of the real life current applications (payrolls, banking applications) are still Cobol applications written some tens of years ago.So, most of companies have to continue using them, it would cost too much if they wanted to convert them to C++.

I would like to request the moderators to open a new forum for COBOL like there are for other programming language.

Great idea ! However, before requesting this, I would like to suggest you to simply start another post with a poll : what programming language are you currently using, or are you planning to use ?- cobol
- C, C++
- Fortran
- Basic
- Java ?
There are already some such polls, but without Cobol. I am sure if you startup such a poll, you will see that almost nobody is currently writing in Cobol. I'm pretty sure more than 99% people will talk about other languages. And that's why there will probably be no Cobol special forum. Because cobol will probably stay as one of these old goodies, still useful, but not so wanted for future applicatons.

Share this post


Link to post
Share on other sites

Dear Friends Last time around I wrote a program named Hello World using COBOL. Today I will try to analyze the program. So I will rewrite the program for your convenience.000100 IDENTIFICATION DIVISION.000200 PROGRAM-ID. HELLO.000300 ENVIRONMENT DIVISION.000400 DATA DIVISION.000500 PROCEDURE DIVISION.000600000700 PROGRAM-BEGIN.000800 DISPLAY "Hello world".000900001000 PROGRAM-DONE.001100 STOP RUN.A COBOL program always has four divisions and these four divisions are always having the same names: i) IDENTIFICATION DIVISION ii) ENVIRONMENT DIVISION iii) DATA DIVISION iv) PROCEDURE DIVISION In Hello World program, lines 000100 and 000200 are the IDENTIFICATION DIVISION. This division is used to mark the basic information about the program. In this program, the IDENTIFICATION DIVISION contains only the PROGRAM-ID, HELLO.Line 000300 is the ENVIRONMENT DIVISION, which is used to identify the environment in which the program is running. Keep in mind that COBOL is intended to run on many unlike types of machines, and this section is used to handle the differences between various computers. In this case, the program has no specialized machine necessities, so the ENVIRONMENT DIVISION is empty.Line 000400 is the DATA DIVISION, which will contain any data that the program operates on. This program has no data, so the DATA DIVISION is empty.Lines 000500 through 001100 are the PROCEDURE DIVISION. This is the meat of the program--the part that does the work planned by the programmer. The PROCEDURE DIVISION contains two paragraphs at line 000700 (PROGRAM-BEGIN) and line 001000 (PROGRAM-DONE). The term paragraph has a special definition in COBOL that will be covered a bit later in today's lesson. All the actual work in this program is done by line 000800.

Share this post


Link to post
Share on other sites

Line 000400 is the DATA DIVISION,

Are the line numbers mandatory ? Or are these numbers here only for convenience ?I remember old Fortran programs had a line number field, which was often left to blank.

Share this post


Link to post
Share on other sites

Programmer

An Introduction To COBOL

 

I am a one time COBOL programmer using MF COBOL version 2.5.60. For a long time I had batch files created to create int, gnt, or exe files. I had to reconstruct my machine a couple of months back and ever since I copied the COBOL compiler back over, after the OS reload, I have been unable to create an int file. It always creates a gnt file no matter what command line info I provide. I really need to be able to create the int files so I can utilize the Animator. I beleive my problem involves the pathing or environment variable(s) that I had to replace from memory. Any help would be greatly appreciated.

 

-question by TonyM

Share this post


Link to post
Share on other sites

how to link the data file in program

An Introduction To COBOL

 

=============================================================

 

FILE-CONTROL.

 

 

 

SELECT PHONE-FILE

 

ASSIGN TO "phone.Dat"

 

 

 

ORGANIZATION IS SEQUENTIAL.

 

=============================================================

 

 

 

Dear friends as shown in above syntax as I am using this syntax in my program to select the dat file.

 

The compiler is giving error in these line

 

I think compiler is unable to link the data file

 

Please help me on this?

 

 

 

-reply by vishal choudhary

Share this post


Link to post
Share on other sites

Differences b/w cobol and microfocus cobol?

An Introduction To COBOL

 

Can someone tell me the major differences between cobol and microfocus cobol?

Share this post


Link to post
Share on other sites

I have been a COBOL programmer for over 13 years and can say that there is still a need for it especially in any application that processes huge volumes of data. In my case I work on a billing application that processes millions of customers with hundreds of millions of charges per month. There is simply no other programming language that can support that volume. There as an effort some time ago to rewrite some of the applications in the billing stream in C++. The COBOL jobs finished in about 3 hours the C++ version was still running two days later. Although there is less need to support mainframe applications there are still us dinosaur programmers out there loving what they do. I am actually doing some work with stored procedures and JAVA now which I am enjoying.Regarding Mircofocus: Microfocus is similar to MVS COBOL except that it does not run on an MVS Platform. It ties more into PC computing. If you search the web I believe there is a Microfocus demo, at least there was when I was going to school. My understanding is that there is a pretty big difference between MF Cobol and MVS Cobol probably similiar to that between IBMs an MACs.

Share this post


Link to post
Share on other sites
Comments on COBOLAn Introduction To COBOL

There seems to be a little confusion out there about COBOL. First, COBOL is far from a "dead" language. Were it so, you probably COULD find a free compiler, but most compilers are quite expensive, and only Fujitsu Cobol has a free compiler with all the bugs removed. Unfortunately, it is based on an old standard, and contains little of the modern capabilities (screen handling, class and property, etc. Handling). For these capabilities, find a deep pocket.

There are an estimated BILLION lines of cobol being used every day. Thousands of front and back ends written in basic, C, C++ provide interactive capabilities to these old work horses, and there has yet to be a better business language developed. When you talk of handling, as an example, a quarter of million transactions a week, as many COBOL systems do, no other language can provide the speed and sheer processing power of COBOL.

There are a number of sites out there that are COBOL cognizant. Google "COBOL FAQ" and watch.

The compilers and the language have evolved with the times. There is very little you cannot do with COBOL, and as for the "translator" type compilers than generate C or C++ code from COBOL code, the exercise defeats the entire purpose of COBOL.

COBOL stands for Common Business Oriented Language.  'Nuff said.

-reply by Dale Hermann

 

Share this post


Link to post
Share on other sites
Need COBOL CompilerAn Introduction To COBOLI am using MS Cobol V2.1 on an XP Machine. During compilation, I am getting an error like Null Pointer Assignment or Memory Overlay error. Compiler doesnt go beyond scanning ENVT DIV. Can you throw some light on the errors and tell me how to proceed. Thanks in advance.-question by Kavitha

Share this post


Link to post
Share on other sites
In responce to your HELLO WORLD programAn Introduction To COBOL

if I am correct the DISPLAY "HELLO WORLD!". Should start in paragraph B which is indented 12 spaces. As it sits right now that would be in violation of Paragraph A.

Paragraph A = 8-11

paragraph B = 12-72

 

I would Also like to know where you downloaded your compiler at. I am using cobol651 compiler.

it has some differences to a regular compiler. 

-reply by Bradley P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.