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
 

 

Find how many times a value has repeated in the array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
prabhucs01
Warnings : 1

New User


Joined: 07 Mar 2005
Posts: 43

PostPosted: Thu Aug 02, 2007 7:30 pm    Post subject: Find how many times a value has repeated in the array
Reply with quote

I have an array of 100 records. I want to know how many times a particular value has repeated in the array.
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Aug 02, 2007 8:01 pm    Post subject:
Reply with quote

Scan through the array and count the number of times "a particular value" is repeated.......
Back to top
View user's profile Send private message
ashwinreddy

Active User


Joined: 16 Sep 2004
Posts: 106
Location: Hyderabad

PostPosted: Thu Aug 02, 2007 8:01 pm    Post subject:
Reply with quote

Can you expand your request whether you should do it in cobol program, if so its simple

like take the 1 array value and compare it with all the other value from array value two

keep on incrementing a counter when you get a match.

cheers
Ashwin
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Aug 03, 2007 12:27 am    Post subject:
Reply with quote

Hello,

Is it acceptable to have the same value in the array more than one time?

If this is not valid, how is the array populated? As the array is being populated, the code could look at the previous entries in the array and determine if this is a "new" value or is it is already in the array.

If you post more detail on your requirement, we will be able to offer better suggestonis.
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Fri Aug 03, 2007 11:52 am    Post subject:
Reply with quote

hi prabhu,

Quote:

I have an array of 100 records. I want to know how many times a particular value has repeated in the array


You can do it using search verb also.
Code:

working-storage section.
01 I       pic  9(3).
01 temp pic  9(3) value '1'.
01  tab1 occurs 100 times indexed by I.
     05  val    pic x(20).
procedure division.
perform para-1
para-1.
        move temp to I.
        search tab1 at end go to para-exit
                 when val(I) not = 'bala'
                          set I up by 1.
          if (I <= 100)
              move I to temp
              add 1 to counter
             go to para-1
          end-if.
para-exit.
         exit.


Please correct me if i am wrong icon_neutral.gif
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Tue Aug 07, 2007 4:25 pm    Post subject: Re: Find how many times a value has repeated in the array
Reply with quote

You could also you inspect tallying.
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 find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm


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