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
 

 

Finding the count of filled elements in an array.

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

New User


Joined: 03 Jul 2011
Posts: 8
Location: india

PostPosted: Wed Nov 02, 2011 11:34 pm    Post subject: Finding the count of filled elements in an array.
Reply with quote

Hi All,

I do have question in OCCURS class in COBOL. I have an array which is of length 100. In that array if I need to know the count of filled element, is there a way to do it through any keyword?

I can do it by reading the array until it meets the NULL value and I can display the count value. But is there any short way to do it?

Example:

A(1) = 5
A(2) = 8
A(3) = NULL
A(4) = NULL

Required O/P = 2; Please suggest me.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Nov 02, 2011 11:40 pm    Post subject: Reply to: Finding the count of filled elements in an array.
Reply with quote

No arrays in Cobol. Table, yes. The length of a Cobol table is length of occurs item time no of occurs.

To your question, don't you keep track of what you put in the table, so that you know how many are there all along without having to do any sort of other stuff? If you read this from a file, there should be a count of the no of entries occupied on the file.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 02, 2011 11:46 pm    Post subject: Reply to: Finding the count of filled elements in an array.
Reply with quote

You could -

01) Keep a counter-variable in WS, adding one to the counter each time an element is added.

02) Use the SEARCH Verb until you find an element that equals LOW-VALUES. To avoid the SEARCH, check element number 100 for not equal to LOW-VALUES (Table is FULL) as well as element number 001 for equal to LOW-VALUES (Table is EMPTY).

Mr. Bill
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: Thu Nov 03, 2011 10:12 am    Post subject:
Reply with quote

Hello,

NULL is not a value - it is a condition. Do you mean x'00' or x'40' or something is "null"?

When you put things into the array, you could save a "high-water" mark and know without looking which was the last element used. . .
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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Group elements using ICETOOL Learncoholic DFSORT/ICETOOL 2 Fri Apr 14, 2017 11:01 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm


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