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
 

 

COBOL array with more than 1 index

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: COBOL array with more than 1 index
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

Site Director


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

PostPosted: Thu Apr 01, 2010 9:55 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Apr 01, 2010 10:35 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Apr 02, 2010 4:16 am    Post subject: Reply to: COBOL array with more than 1 index
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    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 RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm


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