CSCI 465 Midterm Exam Review

This test covers the material on:

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

You may also want to look at the web pages on QSAM, and you may want to use the worksheets on COBOL arithmetic and edited output.

On this particular test, there is very little about macros other than the QSAM macros. The last topic, control break processing, is only about 10 percent of the test. COBOL tables are not included on this test.


QSAM and macros

You need to know the DCB parameters.

You need to know how to open and close files.

You need to know how to use GET and PUT in both modes.

You need to know which registers can be affected by QSAM macros and how.

You need to be aware that DCB data is found here and there in a COBOL program.

JCL

You need to understand the basic structure of a job: line length, columns, character set, // at the beginning of a line.

You need to understand the 3 major kinds of JCL statements (JOB, EXEC and DD) and the parameters for each.

You need to know the comment format.

You need to be aware of JOBLIB and STEPLIB.

Possible questions might involve writing DD statements or interpreting an EXEC statement.

JCL for common steps

You need to understand the compile & link-edit & fetch process and also the compile & load process.

For each of these common steps, you need to know the DD names, where they are used, and whether they are input or output in each step. (For instance, where is SYSLOUT used?) You do not need to memorize the names of the libraries.

You need to understand the basic concepts of buffers and blocking.

Utilities

You should understand IEFBR14 thoroughly. (This is not difficult).

Basic structure of a COBOL program

Data Division entries

Procedure Division code

control-break processing

You need to understand the logic of a control-break program: nested loops, rolling totals, etc.


Lots of Sample questions

True or False

  1. Area B includes columns 12-72.

  2. A reserved word may not be used as a programmer-supplied data name.

  3. Record descriptions must start at level number 01.

  4. Area B includes columns 12-72.

  5. The statement "Perform 100-Process" will implement a loop in COBOL.

  6. A file must be open for input before it can be read successfully.

  7. On a Compute statement with no parentheses, addition and subtraction are done before multiplication and division.

  8. Data names should be as short as possible to cut down on the coding effort.

  9. The following are equivalent:
               If Field-A is Not Greater than Field-B
               If Field-A Not > Field-B

  10. In a nested If, COBOL uses indentation to determine which If or Else a line of code is subordinate to.

  11. The TIME parameter on the JOB statement will override the TIME parameter on the EXEC statement.

  12. QSAM will go to the disk file to read a logical record every time you request a GET operation.

  13. If you code DISP=(NEW,KEEP) for a temporary data set, this will make it permanent.

  14. IEFBR14 can be used to create new data sets.

  15. The REGION parameter on the EXEC card overrides the REGION parameter on the JOB statement.

  16. The TIME parameter on the JOB card states the time allowed for each individual step of the job.

  17. The EODAD parameter is not always necessary in coding a DCB macro.

  18. Absolutely nothing can go wrong in closing a file.

  19. An elementary data item is a data item that is not further subdivided, and thus must have a Pic clause.

  20. The Write verb refers to a file name.

  21. The words 'Procedure Division' start in the A-margin.

  22. In a 3-level control-break program, we read the first record before we start any loops and we read again at the bottom of the outermost loop.

Multiple Choice

  1. Suppose we have these variables:
           01  Field-1    Pic 99V999     Value 54.729.
           01  Field-2    Pic 99V99.

    This statement:

               Move Field-1 to Field-2 Rounde
    
         A.  will place the digits 5472 in Field-2.
         B.  will place the digits 5473 in Field-2.
         C.  will place the digits 54729 in Field-2.
         D.  will cause a message about a syntax error.
         E.  will cause an ABEND at run time.

  2. The COBOL instruction "If A = B or C or D" is equivalent to
         A.   If A = B or C = D
         B.   If A = B or B = C or C = D
         C.   If A = B or A = C or A = D
         D.   If A = B or A = C or C = D

  3. The scope of the If condition is terminated by
         A.  an Else
         B.  an End-If
         C.  a period
         D.  any of the above

  4. The statement "Accept Todays-Date from Date" will place in Todays-Date
         A.  a single digit ranging from 1 to 7.
         B.  6 digits in the form mmddyy.
         C.  6 digits in the form yymmdd.
         D.  a Julian date in the form yyddd.

  5. Which of the following sets of keyword parameters is needed when defining a DD statement for an old non-catalogued permanent dataset?
         A.  DSN, UNIT, SPACE, DISP
         B.  DSN, UNIT, DISP
         C.  DSN, DISP
         D.  DATA, DLM
         E.  None of the above sets of keyword parameters are correct

  6. Which of the following is not true?
         A.  Job names, step names and DD names may be 1 to 8 characters
             long.
         B.  The name (if any) of a temporary file begins with '&&'.
         C.  Every job must have at least one step.
         D.  We must always code the UNIT parameter on a DD statement.
         E.  JOBLIB is the DD name of a PDS containing load modules.

  7. What is the maximum number of tracks available for a data set with a SPACE parameter of (TRK,(6,4))?
         A.  66.
         B.  10.
         C.  64.
         D.  94.
         E.  None of the above.

  8. Which of the following is an INVALID name for a permanent data set?
         A.  KC01234.MYPDS.CS465
         B.  KC01234.MYDATASET.CS465
         C.  KC01234.DATASET.FOR.MYPROG.PART1
         D.  All of the above are valid data set names.
         E.  B and C.

  9. How many bytes are occupied by one PDS directory block?
         A.   28.
         B.  128.
         C.  256.
         D.  512.
         E.  None of the above.

  10. Which of the following is valid input for the Loader / Linkage Editor in the SYSLIN data set?
         A.  Program source code.
         B.  An executable object module.
         C.  A non-executable load module.
         D.  An executable load module.
         E.  A non-executable object module.
         F.  D and E

  11. What does the COND=(0,NE) parameter on an EXEC statement mean?
         A.  If zero is not equal to the return code from the previous step,
             execute this step.
         B.  If zero is not equal to the return code from the previous step,
             skip this step.
         C.  If zero is not equal to the return code from all previous steps,
             execute this step.
         D.  If zero is not equal to the return code from all previous steps,
             skip this step.

  12. Which of the following lists of DD parameters are required to define a temporary work data set to be used ONLY by the step in which the DD statement is coded?
         A.  DSN, DISP
         B.  DSN, UNIT, SPACE
         C.  DSN, UNIT, DISP, SPACE
         D.  DSN, DISP, SPACE
         E.  None of the above

  13. Which of the following creates an object module as a file?
         A.  Assembler.
         B.  Compiler.
         C.  Loader.
         D.  Linkage Editor.
         E.  A and B.

  14. Which of the following creates a load module and then executes it?
         A.  Assembler.
         B.  Compiler.
         C.  Loader.
         D.  Linkage Editor.
         E.  C and D.

  15. How many bytes are occupied by each member in a PDS directory block?
         A.  12.
         B.   8.
         C.  74.
         D.  It depends on the length of the member name.
         E.  A or C, depending on type of PDS member.

  16. Which of the following DD statements represents a load module?
         A.  SYSOUT.
         B.  SYSLOUT.
         C.  SYSLMOD.
         D.  SYSLIN.
         E.  None of the above.

  17. Which of the following must be stored in a PDS?
         A.  An object module.
         B.  A load module.
         C.  A source module.
         D.  A utility module.
         E.  None of the above.

  18. On what JCL statement is the parameter TYPRUN=SCAN coded?
         A.  JOB card
         B.  DD card
         C.  EXEC card
         D.  A or C
         E.  None of the above.

  19. Suppose we have these variables:
           01  Num-1     Pic 99V99         Value   12.89.
           01  Num-2     Pic 999V9.
    What digits are in Num-2 after execution of this statement?
               Move Num-1 to Num-2.
    
         A.  0128
         B.  1280
         C.  1239
         D.  1300
         E.  This move is not allowed.

  20. Which is the correct description of the forward merge sequence for constructing a complete DCB?
         A.  The DCB in the JCL is examined, the DCB in the program is
             examined, and then the label records are examined.
         B.  The DCB in the program is examined, the DCB in the JCL is
             examined, and then the label records are examined.
         C.  The buffers are examined, the OPEN statement is executed,
             and the label records are used to construct the DCB.
         D.  The label records are examined, the DCB in the program is
             examined, and then the DCB in the JCL is examined.
         E.  None of the above.

  21. Suppose we have this variable:
               05  Num-A  Pic  $$$$,$$9.99CR.
    How many spaces will be needed to print Num-A ?
         A.  8
         B.  10
         C.  11
         D.  13
         E.  14

  22. Which of the following sets of keyword parameters is needed when defining a DD card for an old non-catalogued permanent dataset?
         A.  DSN, UNIT, SPACE, DISP
         B.  DSN, UNIT, DISP
         C.  DSN, DISP
         D.  DATA, DLM
         E.  None of the above sets of keyword parameters are correct.

  23. Which of the following DD parameters has a default value, that is, a value that will be used if the parameter is omitted?
         A.  DSN
         B.  UNIT
         C.  SPACE
         D.  DISP
         E.  none of the above

  24. Which of the following cannot be done using IEFBR14?
         A.  catalog a data set
         B.  delete a data set
         C.  uncatalog a data set
         D.  create a new data set or PDS
         E.  grant permission to other users to read or modify a data set

Coding problems, long and short

  1. Open a file named Print-File so that records can be written to it.

  2. Read a record from a file called Student-File, which has already been opened for input.

  3. Write the instruction that should always end the main routine in a COBOL program.

  4. Implement a loop to process all of the records in the Product-File. The BODY of the loop is a procedure called 100-PROCESS, and you want to stop processing records when Eof-Flag is equal to 'Y'.

  5. Using the information in the preceding question, write the last COBOL instruction that should appear in 100-Process.

  6. Rewrite the following statement using the Compute verb:
               Add Num-1 Num-2 Num-3 Giving Num-4 Rounded.

  7. Add Sale-Amt to the accumulator Total-Sales, producing the error message 'TOTAL-SALES TOO SMALL' if the Picture clause for Total-Sales does not have enough digit positions to the left of the decimal point.

  8. Divide Fld-A by Fld-B, rounding the quotient and placing it in Fld-C. Place the remainder in Fld-D.

  9. Write one COBOL statement that will read a record from an input file (In-File) and place that record in the area of Working-Storage defined as Input-Record. If end of file occurs, set the end-of-file flag to 'Y'.

  10. Write the FD and 01 record description for the following input file of sales transactions:
              Columns                       Contents
                1-5                         Item ID
                6-8                         Quantity Sold
                9-14                        Price Each (dollars and cents)
               15-34                        Description
               35-80                        Unused

  11. Using the input record you described in the previous question, write the complete Procedure Division to process all of the records in the file. For each record, print one detail line containing the data from the input record plus the calculated total sale amount (quantity * price). At the end of the report, print out the grand total of all the total sale amounts. Do not print page and column HEADs or anything else extra. Assume that anything you would need to have in the Data Division has been properly defined. Use Prt- as a prefix for data names on the detail line. Use Sum- as a prefix for data names on the summary line.

  12. One of the four divisions in a COBOL program is the Data Division. Name the two sections we use in the Data Division.


And A Few More Problems

  1. Suppose we have a DD statement "//PRINTER DD SYSOUT=*". Write the DCB for using PRINTER in the program. Include all of the necessary parameters and use proper macro coding technique. Assume we want to have 20 records per block.

  2. Each record in an input file represents one sale. The record contains the sale amount as well as the date (in YYYYMMDD format) and the region (20 characters) in which the sale was made. These records are sorted on S-Region, and within the region, they are sorted on S-Date. From this input data, a report is to be printed containing one detail line for each input record, plus a subtotal (on a separate line) for each date, a subtotal (on a separate line) for each region, and a grand total (on a separate line) for the whole company.

    You may assume the main program contains these lines:

               Move 0 to Company-Total.
               Read Sales-File At end Move 'Y' to S-EOF.     
               Perform 100-Process-One-Region until S-EOF = 'Y'.

    Write the procedure division code for 100-Process-One-Region. Do not attempt to write the whole program. (15 points)

    You do not need to show any data division code, but use good data names that show what you are incrementing, saving, or comparing.

  3. When would you need to invent your own delimiter for an in-stream data set?

  4. Write a DD statement to create and catalog a new empty permanent PDS. The DD name should be MYLIB, and the file name should be KCnumber.LIB, using your own KCnumber. It should have enough directory space to hold information on 25 members, and it should have at least 35 tracks of disk space.

  5. Suppose a job has 3 steps STEPA, STEPB and STEPC, in that order, and I want STEPC to execute only if both STEPA and STEPB have return codes greater than 4. What COND should I use in STEPC?

  6. Describe two differences between the DD statement for a new permanent file and the DD statement for a new temporary file having the same DD name and the same SPACE.

  7. Write a DD statement to create and catalog (no matter what happens) a new empty permanent PDS. Invent a valid file name for it, starting with your KCnumber. Use the DD name NEWLIB. It needs at least 31 tracks of space, and it must have enough directory space for at least 14 members.

  8. Find 10 of the many errors in the following JCL statements. (These are not related to each other and are not a complete job.) Circle each error neatly. Then, state briefly what is wrong for each one.
         //MYJOB  JOB, 'MICKEY MOUSE',TIME=(5,),PARM='ALL'
    
         //  STEP1  EXEC IEBPTPCH,REGION=1592
    
         //INPUTDATA  DD  DSN=KC0ABCD.CSCI465.AUTUMN09.HW6.DATA.V1
         //                  UNIT=SYSALLDA,SPACE=(TRK,(5,1)
                          DISP=(OLD,KEEP,KEEP)
    
         //WKSP  DD DSN=&&TEMP,UNIT=SYSALLDA,
         //         SPACE=(TRK,(1,1)),DISP=(NEW,KEEP)

  9. Suppose I am using QSAM in my assembly language program. The DCB for TRFILE is called TRDCB. At some point, I write this line:
              PUT  TRDCB,TRLINE
    At another point in the same program, I write this line:
              GET  TRDCB
    What is the MACRF in this DCB?

  10. Code the COND parameter which will allow STEP2 to run only if the return code from STEP1 is 4 or greater.

  11. One of the four divisions in a COBOL program is the Data Division. Name the other three.

  12. One of the four divisions in a COBOL program is the Data Division. Name the two sections we use in the Data Division.

  13. Suppose we have the following in Working-Storage:
           01  Bonus                   Pic 9(4)V99.
           01  Salary                  Pic 9(5)V99.
           01  Total-Salary            Pic 9(5)V99.
    Now suppose that at some point in our program, Bonus contains the value 2080.00 and Salary contains the value 98000.00. Suppose we now execute this statement:
               Add Bonus to Salary Giving Total-Salary

    (a) What value will appear in Total-Salary?

    (b) If this referred to your total annual salary, would you be happy with this result?

    (c) How can the code be improved to catch errors like this? (This is a short answer.)

  14. Write the DD statement needed to have exclusive access to an existing catalogued data set named TEST1.FAX.

  15. Code the parameter which will reserve 6 tracks of space for a data set. If the file requires more space it should be able to get 5 more tracks at a time.

  16. Suppose an item is defined somewhere in the Data Division as follows:
               05  T-Amount                    Pic S9(4)V9(3).
    How many bytes of space are used to store T-Amount?

  17. Suppose we have the following Select statement in a COBOL program:
             Select In-Data  Assign To DATAIN.
    Assume that the COBOL program input records are instream. The in-stream data may include lines that begin with // or /*. Code the DD statement for this file, including the delimiter.

  18. Suppose we have these variables:
           01  First-Field   Pic X(10)        Value 'MAYBEMAYBE'.
           01  Second-Field  Pic X(6)         Value 'OKOKOK'.
    What are the contents of First-Field after execution of this statement?
               Move Second-Field to First-Field.
  19. Which of the following is not a function of the loader?
         A.  Accepts as input one or more object modules.
         B.  Creates a load module in memory.
         C.  Executes the program.
         D.  Saves the load module as a member of a PDS.
         E.  None of the above.

  20. (2 points) Suppose a job is to consist of 3 steps:
         STEPA needs 704K of memory to execute.  
         STEPB needs 320K of memory to execute. 
         STEPC needs 448K of memory to execute.

    If I want to put the REGION parameter on the JOB statement instead of the EXEC statements, how should it be coded to use no more memory than necessary?