Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

5 level OCCURS

Status
Not open for further replies.

gonzilla

Programmer
Apr 10, 2001
125
US
Hi. I'm new to the forum. It has already helped me out.

I'm doing an assignment for COBOL II in which one of the quesitons is:

Give an exapmle of of a COBOL 85 app that might require a table or array with 5 levels of occurs clauses.

It said to use the internet as a resource to help.

As this is only my second ever programming class, I'm not sure what app might need 5 levels of occurs...it only goes up to 7 right? Any help would be appreciated.

-Gonzilla
 
One reason for organizing data into so many levels is to subdivide it by category, for ease of handling statistically. Say you have a file which shows three years of clicks on a turnstile by date and time and you want to measure the traffic through it. One way would be to put accumulators in a table, like this:

01 TURNSTILE-TABLE VALUE ZEROS.
05 CLICK-YEAR OCCURS 3 TIMES.
10 CLICK-MONTH OCCURS 12 TIMES.
15 CLICK-DAY OCCURS 31 TIMES.
20 CLICK-HOUR OCCURS 24 TIMES.
25 CLICK-MINUTE OCCURS 60 TIMES
PIC 9(5).

You could then read the file, adding 1 to the appropriate accumulator, depending on the date/time in the file. Once the entire file has been processed into the table, you have the table organized perfectly to do a variety of statistical analyses on the turnstile data including, but not limited to:
1. Add all the accumulators for each minute 1, 2, etc. to decide which times of each hour are the busiest.
2. Add all the accumulators for each hour to decide which times of the day are the busiest.
3. Add all the accumulators for each day to decide which days of the month are the busiest.
4. Add all the accumulators for each month to decide which months of the year are the busiest.
5. Any combination of the above, e.g. which hours are busiest in which month, etc.

This is only on example, but it could be applied to any data which could be broken down into categories and sub-categories of those which can be further divided into ...

Hope this helps Betty Scherber
Brainbench MVP for COBOL II
 
Thank you Betty! That makes sense.

Since I had to turn in the assignment before I was able to get a response, I'll show you what I used. If anyone has any comments on my example, please let me know.

01 DEMOGRAPHIC-ARRAY VALUE ZEROS.
05 REGION OCCURS 6 TIMES
10 STATES OCCURS 50 TIMES
15 ETHNICITY OCCURS 10 TIMES
20 AGE OCCURS 10 TIMES
25 GENDER OCCURS 2 TIMES
30 DEMOG-POP PIC 9(10)
(this assumes some things like ethnic groups and only 6 regions)

I guess I'm just not sure how to get the information out of their. Suppose I want to display the population of caucasian males between the age of 20 - 40 living in in the Midwest...how would that be accomplished?

Thanks again for your help.

-Tyler
 
... and thát is the main problem with this kind of monster tables.

You have for example placed STATES within REGION, which would mean that you have a maximum of 50 states per region, meaning a grand total of 300 states !!! I don't think the US is thát big ... Therefore, you will probably not need 50 states per region.

Suppose the mid-west is REGION (2), and the states therein are occurences 1, 2 and 3. Referring to these states lookes like this:
STATES (2, 1), STATES (2, 2) and STATES (2, 3). The problem of this is that you'll have no clue what states these actually are. Anyway: one step further.

Suppose ethnicity caucasian is allways on occurence 1 (no, i'm NOT a white supremacist !!!), the for those three states, the caucasians would be in
ETHICITY (2, 1, 1), ETHNICITY (2, 2, 1) and ETHICITY (2, 3, 1).
Getting headache yet ? No ? Well, you have three more levels to go ...

The key is remembering on what occurence number you've put what; as shown, the meaning of a couple of number isn't exactly clear ...

Good luck !
Ronald.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top