IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL array with more than 1 index


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vd123

New User


Joined: 30 Jul 2009
Posts: 7
Location: Pune

PostPosted: Thu Apr 01, 2010 9:18 am
Reply with quote

Hi,

Can we define a cobol array with mutilple index?

If so. Can anybody share the business/tech requirement behind this?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Apr 01, 2010 9:55 am
Reply with quote

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
View user's profile Send private message
vd123

New User


Joined: 30 Jul 2009
Posts: 7
Location: Pune

PostPosted: Thu Apr 01, 2010 10:10 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Apr 01, 2010 10:35 am
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Apr 02, 2010 4:16 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top