Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Count the records in the file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
psriv20
Currently Banned

New User


Joined: 25 May 2009
Posts: 19
Location: Pune

PostPosted: Tue Dec 20, 2011 6:45 pm    Post subject: Count the records in the file
Reply with quote

Hi All,
Please help me for following case.
Qus: I have one file have 6 records as follow
File1:
A
A
A
B
C
C

I need to create output file as follow.

Output File.
A 3
B 1
C 2

Thanks,
Back to top
View user's profile Send private message

Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Tue Dec 20, 2011 7:04 pm    Post subject:
Reply with quote

Since you listed this in the COBOL section, I presume you want someone to help you write a COBOL program to increment counters and write the results to a file.

Didn't you do something like this in your first programmig course, regardless of what language you used?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2433
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 20, 2011 7:10 pm    Post subject:
Reply with quote

Phrzby Phil wrote:
Since you listed this in the COBOL section, I presume you want someone to help you write a COBOL program to increment counters and write the results to a file.

Didn't you do something like this in your first programmig course, regardless of what language you used?


Maybe the TS can start a new topic in the Job Vacancies (with the other 10
he put there) to find someone with experience enough to solve his problem.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8036
Location: East Dubuque, Illinois, USA

PostPosted: Tue Dec 20, 2011 7:18 pm    Post subject:
Reply with quote

Someone who has been a member of this forum for 2 and 1/2 years certainly should NOT be asking this type of question. Definitely a candidate for the Beginners and Students Forum
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Tue Dec 20, 2011 7:47 pm    Post subject:
Reply with quote

Good day to all!

This has to be a school assignment but who gets the grade for helping you out. Well it goes something like this;
read file at end eof=yes
save char-field
perform until eof=yes
if char-field equal saved-char
increment counter by 1
else
write saved-char with counter
reset counter
save char-field
end-if
read file at end eof=yes
end-perform
Back to top
View user's profile Send private message
psriv20
Currently Banned

New User


Joined: 25 May 2009
Posts: 19
Location: Pune

PostPosted: Tue Dec 20, 2011 7:51 pm    Post subject: Reply to: Count in the file
Reply with quote

Thanks for reply ...
I did but some how my count always come one less than the actual ...

Now i got the issue....
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Tue Dec 20, 2011 10:13 pm    Post subject:
Reply with quote

oops!

On my logic above, define counter with a value of zero and on the reset counter it should be equal to 1 to count the record that cause the unequal condition.
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Wed Dec 21, 2011 12:29 am    Post subject:
Reply with quote

oops again!

I just want to add one last thing, After the end-perform do a last write of the saved-char with counter.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Wed Dec 21, 2011 1:31 am    Post subject:
Reply with quote

So just curious Jose, while more senior and presumably more experienced forum members have implied to psriv20 that he should be able to write this program, and that asking members to write a simple program for him is inappropriate, you have nonetheless done so, yet did not even test your proposed code, even after the first time you realized an error.

How does this help psriv20?

Sure, he may get a working program with little effort, but how about the next time he needs a simple program - he'll have to ask again.

Where's his growth?
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Wed Dec 21, 2011 2:19 am    Post subject:
Reply with quote

I understand your point, Phil, And I didn't see his previous post on the forum. I was just thinking that he's a student by his question and he needed a little bit of help, of course he needs to code is program.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Length of Tape file Mohan Kothakota JCL & VSAM 9 Thu Apr 20, 2017 10:24 pm
No new posts Need help in reading and validating a... ABINAYATHULASI COBOL Programming 8 Tue Apr 18, 2017 11:42 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us