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
 
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: 2504
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm

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