CSCI 465 Assignment 3

Basic COBOL

(50 points) Overview

This assignment is in two parts.


Part A (20 points)

For this part of the assignment, the text of a COBOL program is provided for you, along with the job control language (JCL) needed to submit that program to the IBM S/390 computer for execution.

Your task is to type this text, save it in a file, submit the file for execution, fetch the output, check it to see if it is correct, make any necessary changes to the file and resubmit it (as often as needed until it is correct), and finally print the output file. You will turn in the final printed copy. (Note: You may print a copy even before it is correct whenever you need a printed copy for debugging purposes).

Learning the things in the preceding paragraph is primarily a do-it-yourself project. You should already be familiar with submitting assembler programs to the mainframe from CSCI 360 and the Assignments 1 and 2, and the process is basically identical for COBOL programs.

Output from Assignment 3, Part A will be a line containing the date and time, plus data about one course, as follows:

                         Date:  2009/05/19     Time:  15:18:20:69

                         CSCI 465        External Data Structures
                         Credit Hours:   4
                         Prerequisites:  CSCI 360

If you do not get this output, either you made a typo or you typed something in the wrong column. Both the JCL reader and the COBOL compiler are very fussy about which columns things are typed in. JCL lines (beginning with //) start in column 1. Documentation lines (beginning with a *) start in column 7. "Identification Division" starts in column 8. "Select..." starts in column 12. "FD" starts in column 8 and is followed by 2 spaces, so that "Input-File" starts in column 12. Type the program exactly as given. Do not try to improve it in any way.

The program you turn in should have correct output, and both return codes should be 00. The return codes are in approximately column 43 of line 10 of the first printed page. You should see return codes of 00 for both the COBOL step and the GO step.

When your program is working, print and hand in the "JOB0nnnn" file, rather than the "JOBnnnnn.txt" file.

JCL and COBOL Program

Note to students: You are expected to type (or cut and paste) the text of the COBOL program below exactly as given, including the documentation. In the first two lines of the text, you must substitute your own Z number, name, and bin number. Use the last three digits of your Z number as your bin number. You may learn more if you do not cut and paste.

//KC0nnnnA JOB ,'your name',MSGCLASS=U
//STEP1   EXEC PROC=IGYWCG,PARM.COBOL='FLAG(I,I),APOST,TEST(STMT)'
//*
//COBOL.SYSIN DD *
      ***************************************************************
      * Program Name:  PROG3A
      *
      * Function:      To print data about one computer science
      *                course.
      *
      * Input:         A file containing one course record.
      *
      * Output:        Three detail lines are printed from the data
      *                on the input record.
      *
      * Notes:         None
      ***************************************************************

       Identification Division.

       Program-Id.  PROG3A.

       Environment Division.

       Input-Output Section.
       File-Control.
           Select Input-File Assign to COURSE.
           Select Print-File Assign to PRINTER.
           Eject
       Data Division.

       File Section.

      ***************************************************************
      * The Input-File contains one 80-character customer record.
      * Each record contains the course number, course title,
      * credit hours, and prerequisites.
      ***************************************************************

       FD  Input-File
           Recording Mode is F.

       01  Input-Record.
           05  In-Course-Number           Pic X(8).
           05  In-Course-Title            Pic X(35).
           05  In-Credit-Hours            Pic 9.
           05  In-Prerequisites           Pic X(35).
           05                             Pic X.

      ***************************************************************
      * The Print-File holds the output.  Print-Record is written
      * from detail lines defined in Working-Storage.
      ***************************************************************

       FD  Print-File
           Label Records are Omitted
           Recording Mode is F.

       01  Print-Record                   Pic X(132).
           Eject
       Working-Storage Section.

      ***************************************************************
      *                   Variable Dictionary                       *
      *                                                             *
      *  System-Date-And-Time     Current system date and time.     *
      *                                                             *
      *  Detail-Line-One          Course number and title.          *
      *                                                             *
      *  Detail-Line-Two          Credit hours.                     *
      *                                                             *
      *  Detail-Line-Three        Prerequisites.                    *
      *                                                             *
      ***************************************************************
                                              
       01  System-Date-And-Time.
           05                         Pic X(45)     Value Spaces.
           05                         Pic X(9)      Value 'Date:  20'. 
           05  Sys-Date               Pic 99/99/99.
           05                         Pic X(5)      Value Space.
           05                         Pic X(7)      Value 'Time:  '.
           05  Sys-Time               Pic 99B99B99B99.
           05                         Pic X(48)     Value Spaces.

       01  Detail-Line-One.
           05                         Pic X(45)     Value Spaces.
           05  D1-Course-Number       Pic X(8).
           05                         Pic X(8)      Value Spaces.
           05  D1-Course-Title        Pic X(35).
           05                         Pic X(37)     Value Spaces.

       01  Detail-Line-Two.
           05                         Pic X(45)     Value Spaces.
           05                         Pic X(16)
                 Value 'Credit Hours:'.
           05  D2-Credit-Hours        Pic X.
           05                         Pic X(71)     Value Spaces.

       01  Detail-Line-Three.
           05                         Pic X(45)     Value Spaces.
           05                         Pic X(16)
                 Value 'Prerequisites:'.
           05  D3-Prerequisites       Pic X(35).
           05                         Pic X(37)     Value Spaces.
           Eject
       Procedure Division.

      ***************************************************************
      * 000-Main obtains the system date and time, then calls a
      * subroutine to print it.  It reads the input record, then
      * calls a subroutine to print the detail lines.
      ***************************************************************
       000-Main.
           Open Input Input-File
                Output Print-File.

           Accept Sys-Date from Date.
           Accept Sys-Time from Time.
           Inspect Sys-Time Replacing all ' ' by ':'.
           Perform 100-Print-Header.

           Read Input-File.
           Perform 200-Process-Record.

           Close Input-File
                 Print-File.
           Stop Run.
           Eject
      ***************************************************************
      * 100-Print-Header just prints the system date and time.
      ***************************************************************
       100-Print-Header.
           Write Print-Record from System-Date-And-Time
               After Advancing Page.
           Eject
      ***************************************************************
      * 200-Process-Record fills in each detail line (with
      * appropriate data from the input record) and writes it.
      ***************************************************************
       200-Process-Record.
           Move In-Course-Number to D1-Course-Number.
           Move In-Course-Title to D1-Course-Title.
           Write Print-Record from Detail-Line-One
               After Advancing 2 Lines.

           Move In-Credit-Hours to D2-Credit-Hours.
           Write Print-Record from Detail-Line-Two.

           Move In-Prerequisites to D3-Prerequisites.
           Write Print-Record from Detail-Line-Three.
/*
//GO.COURSE  DD *
CSCI 465External Data Structures           4CSCI 360
/*
//GO.PRINTER DD SYSOUT=*
//

Note to students: The input record follows the //GO.COURSE line and must be typed exactly as shown. Since the course title does not take up all 35 character positions allotted for it in the FD, blanks are used to fill in the remaining character positions. The 4 is in column 44.


Part B (30 points)

In this part of the assignment, you will need to modify the program from Part A to expand it slightly. Instead of reading just one line, it will read a file containing several lines. For each line, it will print output just like what was printed in Part A. We also want to add up the total number of hours.

There are a number of steps in modifying the program. You may need to read about some of the details in the COBOL textbook if they have not yet been covered in class. None of this is difficult.

  1. Make a copy of the entire file.

  2. Change the GO.COURSE statement in the JCL to read:

    //GO.COURSE  DD DSN=KC02314.SUMMER09.CSCI465.HW3,DISP=SHR
  3. Change the program name to PROG3B.

  4. Define an end-of-file flag. This is a 01-level item in the Working-Storage Section. It is normally 1 character, either 'N' for "We have not yet reached the end" or 'Y' for "We have reached the end". Use a Value clause to initialize the flag to 'N'. Put a line in the Variable Dictionary about the flag.

  5. Define a Total-Hours variable. This is a 01-level item in the Working-Storage Section. The Pic clause for it should be "Pic 99". After the Pic clause, give it a Value clause with value 0. Put a line in the Variable Dictionary about the new variable.

  6. Change the "Read" statement by adding an "At end" clause. The idea is that when we attempt to read and find the end, the "At end" clause goes into action and changes the value of the flag. The end of a Read statement is normally "End-Read" (or a period).

  7. Change the "Perform" statement to implement a loop. This is done with "Perform Something until Condition". Here the condition is that the flag becomes a 'Y'. We want to execute 200-Process-Record repeatedly, not 100-Print-Header.

  8. In 200-Process-Record, insert a line as follows: "Add In-Credit-Hours to Total-Hours".

  9. Put another Read statement at the end of the 200-Process-Record subroutine.

  10. Invent a new detail line to print the total number of hours. You can model it after the detail lines. It should print as something like this:
                          Total Hours:   16

  11. After the loop, put in a statement to move Total-Hours to where it belongs on the detail line you just invented.

  12. Just before the "Close" statement, put in a Write statement to print the new detail line you just invented, after double-spacing.

  13. You may need to put in an "Eject" somewhere to make the listing neater.

If all this works correctly, you should be reading the data and printing three lines about each course, and you should print a line at the end giving the total number of hours.


You will need to run both programs and turn in the printouts. Be sure to put your name and other information on each.