Cobol data read problem HELP!

I am helping a friend learn cobol (i dont know jack about it btw :D) and got stuck.
we are using a book called "COBOL From micro to mainframe" that  was picked up at a university book sale.

if you have the book, we are working on 'project 3-6' (inventory parts list)
objective of the program is to read in data (inventory parts list and numbers)
and write a detailed report with a few calculations involved.
i have most the code written except there seems to be data missing to read in!

first off heres the data file to read in.
WIDGETS, SIZE S     1500500960070
WIDGETS, SIZE M     2000750760080
WIDGETS, SIZE L     0005004000090
WHOSIWHATSIS        3501100460100
GIZMOS, TYPE A      2500800360200
GIZMOS, TYPE B      0000500250300
GADGETS, SIZE S     0250180260015
GADGETS, SIZE L     0900280350025

now the numbers there are supposed to represent 5 fields -
                         Beginning on hand
                         ending on hand
                         unit price

the output for the report is supposed to look like this (exactly as printed in book)
                                           *** INVENTORY REPORT ***

                                   BEGINNING  RECIEVED  SHIPPED  ENDING    UNIT    TOTAL
  PART NAME                 ON HAND                                     ON HAND PRICE   VALUE

XXXXXXXXXXXXXXX           999            999            999         999      9999  9999999

                 TOTAL VALUE OF ALL INVENTORY                                              9999999

now i was doin good up until it came time to read in the data... if all those feilds require 3 digits to be read in except for the unit price which requires 4 digits ... then im 3 digits shy on filling the data.
now i find it hard to believe that this book was made with such an error so i must be missing something. can anyone please help
also a little more info about the program....
the processing requirements are:
1. read a file of inventory records, and for every record read:
    a. determine the quantity on hand at the end of the period. this is equal to the quantity
        on hand as the start of the period (contained in the input record), plus the amount
        recieved minus the amount shipped.
     b. determine the value of all the inventory on hand at the end of the period. this is
         equal to the unit price (contained in the input record) multiplied by the quantity
         on hand at the end of the period [computed in part a.]

      c. print a detailed line part containing the part name, quantity on hand at the beginning
         of the period, the amount shiopped, the amount recieved, the quantity on hand at
         the end of the period, the unit price, and all the value of the inventory at the end of
         the period. double-space detail lines

2. when all the records have been read, print the total value of all the inventory on hand at the end of the period.

and thats it, so why is there not enough data provided to fill the 5 fields?

your future y2k programmer (lol yea right)
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

mlmccConnect With a Mentor Commented:
I think you have to calculate the ending on hand

WIDGETS, SIZE S     1500500960070

150                    Beginning on hand
050                    Recieved
096                   shipped
0070                 unit price
CALC                 ending on hand

From the looks of the data, unit price is 3 digits also.  One presumes a typo or an unknown reason for the 9(4).

mlmcc is right, ending on hand would be  (in this example)

ending_on_hand = (150 + 50) - 96 = 104


im assuming the unit price is .70, so total value would be

total_value = 104 * .70 = 72.8

Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Is there any COBOL record set description?

It would look like this:

   05 PART-NAME    PIC X(20).
   05 RECEIVED      PIC 9(03).
   05 SHIPPED       PIC 9(03).
   05 UNIT-PRICE  PIC 99V99.

I am a COBOL pro. So do not hesitate to ask me anything unclear.
The COBOL pro is mistaken!

I believe what the requestor has descibed is a scenario where a variable blocked or varible blocked spanned record format should be used.  Depending on small bits of information at the beginning of the record here is what the balance of the record looks like.

I am DOD certified Computer Specialist and the expert on COBOL compiler validation for DOD.
Arch Brooks
Dear Arch,
very good. What is DOD? Anyhow. Would you please let us all know what the data record means?
Regards, Holly
Hello Holly,

DOD is the United States Department of Defense.   (Army, Navy, Air Force, Marines). Uncle Sam etc.  I recieved a U. S. Congressional Appointment in June 1982 as Computer Specialist.

In the (FD) File Description of a COBOL program identifies physical characteristics of the file itself!  Every FD must have at least one Record Description RD that identifies logical records within the physical block of data.

Record Contains 15 to 350 characters

The above clause tells COBOL the records may or may not be fixed in length.

Logical records of a fixed length of 80 will work fine with this description.  Any record that has at least 15 but not more than 350 characters will work in this scenario and sizes may vary between the minimun and maximum values.

Arch Brooks
Since this is an elementary exercise, a complex file structure is unlikely.  After mimcc pointed out the obvious, the records sure do look like the way HolliStt described.

Now, if you're running on a mainframe or AS/400, you'ld have to know the actual file structure to be able to read it, but if you're running on a PC, it's probably just a simple ASCII text file.
Dear cookre, yep, that's right.
Glad I could help

All Courses

From novice to tech pro — start learning today.