# 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
------------------------------------------------------------------------------------------

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

the output for the report is supposed to look like this (exactly as printed in book)
-----------------------------------------------------------------------------------------------------------------
1234567890123456789012345678901234567890123456789012345678901234567890
*** 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
------------------------------------------------------------------------------------------------------------------
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?

sincerely,
your future y2k programmer (lol yea right)
LVL 8
###### Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x

Commented:
I think you have to calculate the ending on hand

WIDGETS, SIZE S     1500500960070

WIDGETS, SIZE S
150                    Beginning on hand
050                    Recieved
096                   shipped
0070                 unit price
CALC                 ending on hand

mlmcc

0

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

0

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

ending_on_hand = (150 + 50) - 96 = 104

and

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

total_value = 104 * .70 = 72.8

~b
0

Commented:
Is there any COBOL record set description?

It would look like this:

01 PART-RECORD.
05 PART-NAME    PIC X(20).
05 BEGINNING-ON-HAND 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.
0

Commented:
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.
Sincerely,
Arch Brooks
0

Commented:
Dear Arch,
very good. What is DOD? Anyhow. Would you please let us all know what the data record means?
Regards, Holly
0

Commented:
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.

Regards,
Arch Brooks
0

Commented:
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.
0

Commented:
Dear cookre, yep, that's right.
0

Commented: