Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Recs

Status
Not open for further replies.

gmupatsfan

Technical User
Feb 18, 2001
4
0
0
US
Need help with 1. reading in 2 records and then printing.

the 2 recs share some of the same data such as userid

how do I do this since the records are in the same file?

do I have one in-rec. or two?

first record: userid, state, age
second reocrd userid, favorite number

output needs to be on one line as follows

userid, state, age, favorite number

any ideas?
 
I have no idea how to read in more then one record but my guess would be it would have something to do with using the userid as the primary key.. probably not alot of help..
 
Hi G,

I don't want to do your assignment for you, so I'll give you a hint and ask a question (I'll expect an answer).

Hint - read about "redefines".
Ques - have you learned about loops yet?

Hope this gets you started. Jack.
 
Jack,

Thanks! That's a big help. I know about redefines and am reading up on it now. I don't expect you, or anyone, to do my homework -- I just needed a hint. I haven't gotten to loops yet although I do know what they are.

I'll test it and let you know how I'm coming along.

Again, thanks for the help.

 
Hi G,

Thanx for the courtesy of a reply. I'm glad you don't want anyone to do your homework, but if you'll read the post titled "please help" from hhouse on 2/12 you'll understand my concern and get a good laugh as well. Anyway,

I forgot to mention that multiple 01 levels in an FD constitutes an implied redefines, so you can define both recs as 01 levels and do 2 reads, each referencing the data it needs in one or the other of the 01 levels. Just remember that each read will overlay the data from the previous read.

Regards, Jack.
 
Jack,
I have another question - I think I've come up with a solution.

In working storage I have
05 Flag Pic 9 Value 0

then, in the main module I have
read in-file at end move 1 to flag
perform 200-rtn until flag=1.

what does this mean? what is flag????? That is, how is flag different from EOF?

 
Hi G,

The only place in your pgm that an EOF can be sensed is in a read statement. Since that is a crucial event you may want to make its occurance known to other parts of your pgm. You'll notice that in the "at end" clause of your read, a 1 is moved to "flag". It could have been called fred or sam or lucy. Its just a one byte field in your pgm used to signify that EOF was(1) or wasn't(0) reached on the file.

A better (more descriptive) name for flag would have been
ip-eof-flag or some such. Remember, a COBOL program is a unique device. I say device because it solves a problem. I say its unique because it serves as its own maintenance manual. So, you have to solve the problem and write the manual at the same time. The solving the problem part is obvious, but the manual part isn't, unless you're the guy that gets the phone call at 3 am.

Regards, Jack.
 
gmupatsfan,

just to add a bit to slade's reply:

a "flag" generally is a way to signal if an event has happened yet, or not. It indicates one of two states, either yes or no, true or false, etc. A flag is used commonly to signal en end-of-file state, such as in your example, but flags can be equally useful for other types of conditions. Extensive use of flags should be avoided, though, because they tend to get confusing, and often other - and better - ways are available.

Good luck !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top