Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 967
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: 2445
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: 8195
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: 112
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: 112
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: 112
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: 967
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: 112
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 Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 1 Wed Dec 06, 2017 1:50 am
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
No new posts Moving a PS file as body of a mail! Vignesh Sid JCL & VSAM 4 Tue Nov 21, 2017 9:23 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us