I open COBOL as shown above. First I select programs, then MF 32bit Graphic Tools and then Animator V2. The screen will look like this.  Note it may ask you about a tutorial etc.  Click no or cancel.



This is the workspace you will use.  To open a file on your disk, select file and then open for edit.



I browse to find the file I want to open.  In this example it is on the root of the A drive.


Note Object program is a result only if code is clean

Flowchart: Magnetic Disk: Object/Machine Language ProgramFlowchart: Display: Screen showing results of compileFlowchart: Magnetic Disk: Source



Note that the file names all have the .CBL extension.  This extension is given to the program that the programmer writes.  The SOURCE CODE.  It is not yet turned into machine language.  The result of the compile, will be OBJECT or MACHINE LANGUAGE code that is ready to execute, providing the compile was clean.  If there are errors, then the errors must be fixed and the program recompiled.  More about that later in the handout.














I have now opened the COBOL program - one of the ones that are part of the first COBOL assignment.  Notice that in the SELECT statement near the top I tell the program that the data file we will be using is EMPLOYEE.DAT and that it is located on the root of the A drive.  Note that the complete program is not visible in this picture.



I now want to compile the program.  To do this I click on COBOL and then Check program.


When I tell it to compile it goes through and checks the code.  If there is a syntax error, it will let me know.  In this example the code is clean so it shows the line filled in and the total messages equal to 0.  I then use file/close to close the file.  Next I need to open the file for execution.



Since the compile is done and there were no errors, I am going to open the Object/Machine Language Code so I can execute the program. Note that when I browse for the object/machine language program, all of the extents are .int.



To run the program, select execute and the then run.  This will execute the object/machine language program with the .int extension. Note that there is also a restart application.  If you want to restart the application, in other words run it again, you click on restart application and the first instruction is highlighted.  Then you can do execute/run.




To see the screen, you need to click on the Animator as shown above. 




When the program is run the results appear in a window because I used display to the screen  If I had wanted to print a report I would have had to set up a print file and a print line, all of which takes more code.  The stop run that you see above tells you the program executed successfully.  Note there are varieties in color etc. that would make this look better, I stayed with the default. 

When you are finished looking at the output, click OK to return to the COBOL editor.


Now I am going to make an error in the code so you can see how it handles errors.



I changed the name of the field I am testing to EDUCATION in the IF statement and COBOL tells me there is an error.  EDUCATION has not been defined so it cannot process a comparison with EDUCATION.  Note that when I described the file, I called the field ED.


The errors have been pointed to with the Error indicator and a message at the bottom indicates there is a problem.  Note that the problem was that I wrote the field name as EDUCATION not ED. As a result, COBOL then has problems with the entire IF and points that out. 

Just as a side note.  Sometimes COBOL is off by one line when dealing with errors because it did not figure out that there was a problem until it got to the next line.  I will now fix the error.  I then need to recompile to see if I was successful. 



The compile is clean.  Now I can close and then open for execution and run the program.  If any errors occur at that point, they are logic errors because I did not ask the right questions or do the right processing.