Solved

Cobol data read problem HELP!

Posted on 2004-08-08
11
486 Views
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
                         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
------------------------------------------------------------------------------------------------------------------
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?

sincerely,
your future y2k programmer (lol yea right)
0
Comment
Question by:ViRoy
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 22

Expert Comment

by:cookre
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).

0
 
LVL 100

Accepted Solution

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

Expert Comment

by:bramsquad
ID: 11764423
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
 
LVL 1

Expert Comment

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

Expert Comment

by:abrooks
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.
Sincerely,
Arch Brooks
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Expert Comment

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

Expert Comment

by:abrooks
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.

Regards,
Arch Brooks
0
 
LVL 22

Expert Comment

by:cookre
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.
0
 
LVL 1

Expert Comment

by:HolliStt
ID: 11821922
Dear cookre, yep, that's right.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 11857779
Glad I could help

mlmcc
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 103
sumNumber challenge 16 99
if loop in java 3 114
Modbus - whats the maximum I can store in one register? 4 75
This article will show, step by step, how to integrate R code into a R Sweave document
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now