CSCI 465 Final Exam Review

This test covers the material on:

This test includes true-false and multiple-choice questions and questions with written answers, some short and some longer. It will be an open-book exam; you may bring your notes and books and your programs and a calculator. Do not bring a computer.

In studying: go over what you did in the homework, and go over the quizzes.

It is intended that most of the questions will be about material included on assignments 5 through 8.

On this particular test, there is nothing about QSAM or the other macros.


COBOL features

In particular, this includes Copy, Redefines, String and Unstring, and the Usage clause, but it may also include whatever else we have been doing in COBOL.

COBOL tables

How do we define a table? Subscripted or indexed? In order on a specific field? Variable-size?

How do we use Search and Search All? How do we change the value of an index?

Possible questions might involve defining a table or doing some elementary table processing.

COBOL Sort and Merge

What are the JCL requirements for using Sort or Merge? What is an SD and where does it appear?

You need to understand the elementary Sort with Using and Giving.

Also understand input and output procedures, and how to write them.

What are the various special registers we can use with Sort or Merge?

Possible questions might involve writing a Sort or Merge statement and/or writing an input or output procedure.

Linkage

Static and dynamic calls in COBOL, and the JCL requirements for each.

Passing arguments by reference or by content.

Linkage Section and Procedure Division statement.

Return code from a COBOL program

GoBack versus Stop Run.

Utilities

This refers to IEFBR14, IEBPTPCH, IEBGENER and DFSORT.

Understand the control statements for IEBGENER and for DFSORT. Also try to be familiar with their JCL.

Understand what each of the utilities is used for.

JCL Procedures

Understand the sequence of events in creating a JCL procedure.

Understand the kinds of changes we can make when we execute a procedure.

Our big example of a procedure is IGYWCG. Look at it.

A likely question is to execute a procedure making specific changes.


Sample Questions

  1. Suppose we are sorting a file containing an unknown number of records using the COBOL Sort verb. In each case, decide whether
             (1)  you would need to use an input procedure or
             (2)  you would need an output procedure or
             (3)  you could use either one or
             (4)  it can't be done in one operation (or not by any simple
                  means we have covered).

    These are all independent of each other. At least one is hard.

    1. Make each record 25 bytes longer.

    2. Sort only the first 250 input records.

    3. Skip any record with a particular value in columns 24-35.

    4. Sort only the last 250 input records.

    5. Eliminate duplicate records.

  2. What are the required DD names for the DFSORT utility, and what are they use for? What are the required DD names for the IEBPTPCH utility, and what are they used for?

  3. Suppose you are writing a COBOL program which you will compile and then execute using the loader. You want to use a table which lists the names of the 12 signs of the zodiac. The code for declaring the table and filling it with data has already been written and is stored in a member named ZODIAC of a catalogued PDS called C465.TOOLS.
    1. What do you need to include in the JCL (and in which step) to do this? Be specific.

    2. What do we need to include in the COBOL source code?

  4. Name 3 different uses we have seen for partitioned data sets in this course.

  5. Suppose we have the following in Working-Storage:
           01  Test-Table.
               05  Level-1             Occurs 10 times
                   10  Field-1-1       Pic X(16).
                   10  Level-2         Occurs 9 times.
                       15  Field-2-1   Pic 9(7)V99   Usage is Comp-3.
                       15  Field-2-2   Pic 99V99     Usage is Comp.
                   10  Field-1-3       Pic X(3).

    How many bytes of space does Test-Table occupy? Show your calculation.

  6. Suppose a program called MAJOR written in assembly language, is calling a subprogram called MINOR, written in COBOL. There are 4 parameters: HOURS, OVERTIME, RATE, TOTALPAY, in that order. The parameter list contains the addresses of the 4 fields which are defined in MAJOR as follows:
             HOURS    DS  PL2
             OVERTIME DS  PL2
             RATE     DS  PL3
             TOTALPAY DS  PL5
    
    where HOURS    = number of hours worked,
          OVERTIME = number of overtime hours worked,
          RATE     = the hourly rate of pay in dollars and cents, and
          TOTALPAY = the employee's total pay amount in dollars and cents.
    1. Write the Linkage Section for MINOR.

    2. All MINOR does is calculate TOTALPAY using this formula:
               TOTALPAY = (HOURS + 2 * OVERTIME) * RATE.

      Write the complete Procedure Division code for MINOR. Do not change the values of HOURS, OVERTIME, or RATE.

  7. Given the following procedure:
    //COMPL  PROC CPARM=OFFSET,
    //            SNAME='KC0SOB1.OLDPGM',
    //            SSPACE='(TRK,(3,3))',
    //            SUNIT=SYSALLDA,
    //            SDISP=
    //COB    EXEC PGM=IGYCRCTL,REGION=2048K,PARM='&CPARM'
    //STEPLIB  DD DSN=IGY340.SIGYCOMP,DISP=SHR
    //SYSIN    DD DSN=&SNAME,UNIT=SYSALLDA,DISP=SHR
    //SYSLIN   DD DSN=&&MODULE,DISP=(NEW&SDISP),UNIT=&SUNIT,SPACE=&SSPACE
    //SYSUT1   DD DSN=&&SYSUT1,UNIT=&SUNIT,DISP=(NEW,DELETE,DELETE),
    //            SPACE=(CYL,(1,1))
    //SYSUT2   DD DSN=&&SYSUT1,UNIT=&SUNIT,DISP=(NEW,DELETE,DELETE),
    //            SPACE=(CYL,(1,1))
    //SYSUT3   DD DSN=&&SYSUT1,UNIT=&SUNIT,DISP=(NEW,DELETE,DELETE),
    //            SPACE=(CYL,(1,1))
    //SYSUT4   DD DSN=&&SYSUT1,UNIT=&SUNIT,DISP=(NEW,DELETE,DELETE),
    //            SPACE=(CYL,(1,1))
    //SYSUT5   DD DSN=&&SYSUT1,UNIT=&SUNIT,DISP=(NEW,DELETE,DELETE),
    //            SPACE=(CYL,(1,1))
    //SYSUT7   DD DSN=&&SYSUT1,UNIT=&SUNIT,DISP=(NEW,DELETE,DELETE),
    //            SPACE=(TRK,(2,4))
    //SYSPRINT DD SYSOUT=A
    //       PEND

    Write the IBM JCL that will execute the above procedure and make the following changes. If a symbolic parameter exists for that field, you must use it to make the change instead of overriding the existing parameter.

    1. execute the compiler procedure COMPL

    2. give the compiler the parameters of TEST and FLAG(W,W)

    3. change the name of the source code dataset to KCnumber.SOURCE

    4. add a SYSUT6 DD card including all the necessary parameters

    5. change the space on SYSUT7 to (CYL,(1,1))

    6. change the disposition of the SYSLIN file in the COB step so that it has the parameter of DELETE in the normal end position and DELETE in the abnormal end position.

  8. Write the Linkage Section and Procedure Division statement that would be needed to accept an EXEC card PARM of the format 'NNN,XX', where XX represents a two-character state code, and NNN represents a three-digit grade point average with one whole digit and two decimal digits.

  9. Given the fields which are defined, not necessarily in this order, in the Working-Storage Section of a COBOL program:
             01  Salary                    Pic 9(5) Comp.
             01  Overtime                  Pic 9(4) Comp.
             01  Total-Salary              Pic 9(6) Comp.
    1. Write the COBOL statement which will invoke the external assembler subroutine named TOTALPAY and pass in the three parameters listed above.

    2. Write the assembler code needed to get the address of Salary into register 2, Overtime into register 3, Total-Salary into register 4. (Assume that IBM standard entry and exit linkage has already been coded.)

    3. Code the assembler statements necessary to add Salary to Overtime and place the result in Total-Salary.

  10. Write the JCL for a complete job (every line) which will use IEBGENER to create 2 members of an existing PDS called FINAL.LIB. The first member is called EINS and should contain these two lines:
                     This is line 1 of EINS.
                     This is line 2 of EINS.

    The second member is called ZWEI and should contain these two lines:

                     This is line 1 of ZWEI.
                     This is line 2 of ZWEI.

    You will need to supply the data as in-stream data.

  11. The "Using" and "Output procedure" options are mutually exclusive.
         A.  True                          B.  False

  12. Suppose we want to use the COBOL Sort verb to sort an input file called Old-Data into an output file called Old-Data-Sorted. The workspace file is called S-W-File, and its data record is:
           01  S-W-Record.
               05  S-W-Key                 Pic X(10).
               05  S-W-Code                Pic X(5).
               05  Other-Data              Pic X(85).

    The Sort statement is this:

               Sort S-W-File
                 On Descending Key S-W-Key
                 Using Old-Data
                 Giving Old-Data-Sorted.

    Assume none of the files involved has been opened or closed yet.

    1. Now suppose we want to eliminate all records in which S-W-Key has the value 'ABCDE'. Would it be better to do this using an input procedure or an output procedure?

    2. Instead of (a), suppose we want to create a duplicate of each record, so the sorted file will contain two copies of each record. Would it be better to do this using an input procedure or an output procedure?

  13. Suppose we are using the COBOL Merge verb to merge 3 files: File-A, File-B, and File-C. The 3 files have the same record formats, and each has been sorted in descending order on a key field which is 9 bytes long, starting in column 11 of the record.

    Assume we have a Sort-Work-File as usual, with data record

             01  S-W-Record.
                 05              Pic X(10).
                 05  S-W-Key     Pic X(9).
                 05              Pic X(51).

    We want to eliminate duplicates, keeping the first copy of each set of duplicates.

    Write the Merge statement we need in the Procedure Division, and write the output procedure.

  14. Write the JCL and control statements we need to use DFSORT to sort an input file, KC0CSCI.SORTME (catalogued), into an output file, KC0CSCI.SORTED (catalogued), in descending order on a unique key field which is in bytes 40 through 47 in each record. All records should be included, and no additional processing is done. Each record is 80 bytes long, and the input file contains approximately 250 records.

    Instead, we could use the COBOL Sort verb to do the job. Assume we have a Sort-Work-File as usual, with data record

             01  S-W-Record.
                 05              Pic X(39)
                 05  S-W-Key     Pic X(8).
                 05              Pic X(33).

    Assume KC0CSCI.SORTME and KC0CSCI.SORTED have COBOL names Sort-Me and Sort-Out.

    Write the Sort statement we need in the Procedure Division with the Using and Giving options.

    Now suppose we want accomplish exactly the same task, but we want to use the Sort verb with an input procedure and an output procedure.

    Write the Sort statement we need in the Procedure Division. Also write the input procedure, the output procedure, and any Working- Storage items we may need to make this work.

  15. Suppose a program called MAJOR written in assembly language, is calling a subprogram called MINOR, written in COBOL. There are 4 parameters: HOURS, OVERTIME, RATE, TOTALPAY, in that order. The parameter list contains the addresses of the 4 fields which are defined in MAJOR as follows:
             HOURS    DS  PL2
             OVERTIME DS  PL2
             RATE     DS  PL3
             TOTALPAY DS  PL5
    
         where HOURS    = number of hours worked,
               OVERTIME = number of overtime hours worked,
               RATE     = the hourly rate of pay in dollars and cents, and 
               TOTALPAY = the employee's total pay amount in dollars and 
                          cents.
    1. Write the Linkage Section for MINOR.

    2. All MINOR does is calculate TOTALPAY using this formula:
               TOTALPAY = (HOURS + 2 * OVERTIME) * RATE

      Write the complete Procedure Division code for MINOR. Do not change the values of HOURS, OVERTIME, or RATE.

  16. Suppose a program called BOSS, written in assembly language, calls an external subprogram called MINION, written in COBOL, and passes it three parameters. The first is a number, RECEIPTS, 9 digits long, in packed decimal format, representing an amount of money in dollars and cents. The second, FLAG, is 1 character. The third is a numeric field, NET, like the first one.

    If FLAG = 'Y', MINION should set NET = RECEIPTS. If FLAG = 'N', MINION should set NET = RECEIPTS * 0.95. If FLAG is 'Y' or 'N', MINION should provide a return code of 0, but if FLAG is some other value, MINION should provide a return code of 99 and do nothing with NET.

    1. Write the Linkage Section for MINION.

    2. Write the complete Procedure Division for MINION.

  17. Suppose a COBOL program is being written that will accept an EXEC-line parameter of the form 'DDMMYYYY,Johnson', that is, an 8-digit date followed by a comma and a name (up to 15 characters).
    1. Write the Linkage Section needed by the COBOL program.

    2. If the person using the program supplies the date but forgets to include the name field in the EXEC-line parameter, how can the program detect this fact?

  18. Which of the following (A - D) is true about passing parameters in COBOL?
         A.  The default is to pass all parameters By Content.
         B.  A parameter passed By Reference cannot have its value changed
             by the subprogram.
         C.  Parameters can be passed By Content only if we are using the 
             CONTENT compiler option.
         D.  If we change the value of a parameter which has been passed
             By Reference, then we are also changing the value of the  
             corresponding field in the calling program.
         E.  None of the above is true.

  19. Suppose I want to create a macro library.
    1. Write the JCL statement needed to create a new permanent PDS. The file name should be CSCI465.MACLIB. Give it at least 31 tracks of space. You can figure out the DD name to use from part (b) below.

    2. What utility should I use to create the members of my new PDS? The input will be in-stream data.

    3. When I write an assembly-language program, where will the macro library be represented in the JCL?

  20. Suppose we are running IEBGENER with the following control statements:
         GENERATE MAXFLDS=7,MAXLITS=3
           RECORD FIELD=(9,21,,1),  
                  FIELD=(10,11,,10),
                  FIELD=(1,1,,20),  
                  FIELD=(2,'19',,21),
                  FIELD=(6,41,,23),
                  FIELD=(1,30,,29),
                  FIELD=(1,'O',,30)

    The input records are each 52 characters long. Each contains a first name (10 characters), a last name (10 characters), a Social Security Number (9 digits), a code indicating sex (1 character), a telephone number (10 digits), a date of birth (6 digits), and an account number (6 characters).

    One of the records is:

         JOHN      PUBLIC    918320754M8155551234740516UVWXYZ
         1234567890123456789012345678901234567890123456789012

    (The line of numbers is a ruler so you can count columns easily.)

    The output records are each 30 characters long.

    When the above input record is processed, what will the resulting output record contain?

         _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
         1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0

    Which fields (how long and where) in the input record were not copied at all?

  21. A file contains the following records:
             ABCDEF  This is record 1.
             GHIJKL  This is record 2.
             MNOPQR  This is record 3.
             STUVWX  This is record 4.
             YZABCD  This is record 5.
             EFGHIJ  This is record 6.
             KLMNOP  This is record 7.
             QRSTUV  This is record 8.
             WXYZAB  This is record 9.

    The records are each 25 bytes long.

    We want to create 3 new members RHO, SIGMA and TAU of a new PDS. RHO should contain the the first 4 records, SIGMA should contain the next two records, and TAU should contain the last 3 records.

    Write the IEBGENER control statements we need to do this.

  22. Name 3 different COBOL special registers and describe how they are used.

  23. Name 3 items we may have listed in a job before we reach any EXEC statements.

  24. Suppose I have a job in which the DIG step creates a file named EXTRACT.DATA. At the end of the job, the file still exists.

    Suppose I run the job twice. What will happen the second time?

    Suppose I add a step to my job at its beginning, deleting EXTRACT.DATA. Now suppose I run my job, and then some helpful co-worker happens to delete EXTRACT.DATA. What will happen next time I run my job?

  25. Write a complete job (every line) which will create and catalog a new permanent empty PDS called FINAL.LIB. It should have at least 47 tracks of space and enough directory space for at least 16 members.

  26. I have an input file containing somewhere between 35 and 50 records (in no particular order) which I want to put in a table in my COBOL program. The record format looks like this:
           01  In-Record.
               05  In-Key                      Pic X(10).
               05  In-Data                     Pic X(110).

    I want to be able to search the table using a binary search with the first 10 bytes in each record as the key field. I will be looking for a value which is in a field called Target-Key.

    I need to do some of the following. (I may need to do other things as well.) Mark the ones which are not needed to do the search.

         ___ Use DFSORT to sort the input file in descending order on 
             the first 10 bytes in each record.
    
         ___ Define a table big enough to contain 50 entries.  (Use T- as
             a prefix for items in the table.)
    
         ___ The table should be indexed.  (Call the index T-X.)
    
         ___ The table definition should say "On Descending Key T-Key".
    
         ___ The table definition should say "On Ascending Key T-Key".
    
         ___ Initialize the table to High-Values.
    
         ___ Initialize the table to Low-Values.
    
         ___ Set T-X to 1.
    
         ___ Move 1 to T-X.
    
         ___ Use a Perform...Varying loop to load the table from the sorted
             input file.
    
         ___ Count the records.
    
         ___ Use Search All to do the actual search of the table.
    
         ___ Use Search to do the actual search of the table.

  27. Suppose my job has 2 steps, BIG and LITTLE, in that order. The BIG step executes a JCL procedure called POLY, which has 3 steps: APRIL, MAY and JUNE, in that order. The LITTLE step executes a program, IEBWHAT. The APRIL and JUNE steps may have any return codes, but I only want to execute LITTLE if MAY had a return code of 8 or more.

    What COND should I put on LITTLE?