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
 
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: 7314

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: 2504
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 ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Finding the plan when code compiled u... Ahemad DB2 1 Fri Dec 01, 2017 6:38 pm
No new posts Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm

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