How to read a record from n no of records in a file.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

How to read a record from n no of records in a file.

Postby shanshar » Fri Nov 18, 2011 2:40 pm

Suppose i have one file having number of records..for ex..

ABC = 12
BCD = 24
EFG = 3
FGH = 44
GHI = 5
IJK = 67
JKL = 79
...
...
NNN = 999

Now i have to search the value of "GHI" from this file. if its find it will dispaly the value "5" else will display no record found.

My querry is how to code this in cobol.
PLeaes let me know the code as am new to cobol dont have an idea to achieve this.
shanshar
 
Posts: 4
Joined: Tue Nov 15, 2011 5:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read a record from n no of records in a file.

 

Re: How to read a record from n no of records in a file.

Postby enrico-sorichetti » Fri Nov 18, 2011 2:45 pm

looks that You have also issues with the logic !
start writing the pseudo code in plain words and then worry about the COBOL part

here is a very good link with lots of examples clearly explained
http://www.simotime.com


Pleaes let me know the code as am new to cobol dont have an idea to achieve this.


this is a help forum, not a do it for me one... :evil:
if You do not have the slightest idea on how to do it
then the training institute You are attending sucks, You are just wasting time and money
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: How to read a record from n no of records in a file.

Postby dick scherrer » Sat Nov 19, 2011 11:05 am

Hello,

PLeaes let me know the code as am new to cobol dont have an idea to achieve this.shanshar

We will help you with your classwork, but we will not do the work for you. . .

If you are stuck on how to aproach this, suggest you take a few bits of paper and write the contents of on record on each bit of paper. Stack them and voila - you have your input file. Now, think about what tyou need to do to get to the desired result. As Enrico suggested, consider pseudo-code to work thru the mechanics. Once you can do this "by hand", incorporate it into COBOL code.

If you get stuck coding, post what you have tried and your doubt. Someone should be able to clarify.

It is our goal to help you learn and the more we do, the less you learn.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post