View previous topic :: View next topic
|
Author |
Message |
vd123
New User
Joined: 30 Jul 2009 Posts: 7 Location: Pune
|
|
|
|
Hi,
Can we define a cobol array with mutilple index?
If so. Can anybody share the business/tech requirement behind this? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, you can use more than one index for a table.
At the top of the page is a link to "IBM Manuals". Look in the Language Reference for your version of cobol for specifics.
Any such requirement would be determined by the developer. The compiler merely provides the capability. |
|
Back to top |
|
|
vd123
New User
Joined: 30 Jul 2009 Posts: 7 Location: Pune
|
|
|
|
Thanks for the reply,
I am keen on the scenario which demands this kind of code set?
Can anyone please share their experiences? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I am keen on the scenario which demands this kind of code set? |
Why? Nothing "demands" this. It is just an option. . .
It is better to use a solution to meet a requirement rather than have a solution in need of a requirement.
If you have something you want to do and you describe this, someone may have a more useful suggestion. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
A second index comes in real handy when you set the index-maximum in housekeeping and use it as the high-water mark throughout program execution.
Code: |
03 WS-FWORD PIC 9(08) COMP.
03 WS-ARRAY-REC.
05 WS-ARRAY-ENTRY OCCURS 100 TIMES
INDEXED BY X-WS-AE, X-WS-AE-MAX
PIC X(24).
DIVIDE LENGTH OF WS-ARRAY-REC BY LENGTH OF WS-ARRAY-ENTRY (1)
GIVING WS-FWORD.
SET X-WS-AE-MAX TO WS-FWORD.
|
WS-FWORD calculated to 100 so the MAX-INDEX was set to its maximum equivalent OCCURS value.
Bill |
|
Back to top |
|
|
|