IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Count the records in the file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Senior Member


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

PostPosted: Tue Dec 20, 2011 7:04 pm
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 20, 2011 7:10 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Dec 20, 2011 7:18 pm
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: 121
Location: Puerto Rico

PostPosted: Tue Dec 20, 2011 7:47 pm
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
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: 121
Location: Puerto Rico

PostPosted: Tue Dec 20, 2011 10:13 pm
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: 121
Location: Puerto Rico

PostPosted: Wed Dec 21, 2011 12:29 am
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

Senior Member


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

PostPosted: Wed Dec 21, 2011 1:31 am
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: 121
Location: Puerto Rico

PostPosted: Wed Dec 21, 2011 2:19 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top