Cobol data read problem HELP!

Posted on 2004-08-08
Last Modified: 2013-11-25
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)
Question by:ViRoy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
LVL 22

Expert Comment

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

LVL 101

Accepted Solution

mlmcc earned 500 total points
ID: 11749925
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


Expert Comment

ID: 11764423
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 11803590
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.

Expert Comment

ID: 11812811
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

Expert Comment

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

Expert Comment

ID: 11819328
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
LVL 22

Expert Comment

ID: 11821481
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.

Expert Comment

ID: 11821922
Dear cookre, yep, that's right.
LVL 101

Expert Comment

ID: 11857779
Glad I could help


Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question