Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
What is Data Type of Index of the Array.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
rgupta71

New User


Joined: 21 Jun 2009
Posts: 60
Location: Indore

PostPosted: Tue Feb 02, 2010 11:57 am    Post subject: What is Data Type of Index of the Array.
Reply with quote

Hi Experts,

I have defined an array as follows
10 ACTIVITY-TABLE-AREA.
15 ACTIVITY-TABLE OCCURS 1 TO 5000 TIMES
DEPENDING ON TBL-CTR
INDEXED BY INDEX.

And a variable SAVE-INDEX as S9(3) COMP-3.I want to save the index of array in a variable. When I am trying

MOVE INDEX TO SAVE-INDEX it is giving an error "INDEX was defined as a type that was invalid in this context."

Is this possible to save index of array in a variable?

Thanks,
Rahul Gupta
Back to top
View user's profile Send private message
References
PeterHolland

Active Member


Joined: 27 Oct 2009
Posts: 531
Location: Netherlands, Amstelveen

PostPosted: Tue Feb 02, 2010 1:24 pm    Post subject:
Reply with quote

I guess that INDEX internally is a fullword binary.
So you have to use a cobol equivalent.

01 SAVE-INDEX PIC S9(9) BINARY.
Back to top
View user's profile Send private message
Mathiv Anan

New User


Joined: 23 Jul 2008
Posts: 94
Location: India

PostPosted: Tue Feb 02, 2010 1:55 pm    Post subject: Reply to: What is Data Type of Index of the Array.
Reply with quote

Try this.

Set SAVE-INDEX to INDEX
Back to top
View user's profile Send private message
rgupta71

New User


Joined: 21 Jun 2009
Posts: 60
Location: Indore

PostPosted: Tue Feb 02, 2010 2:12 pm    Post subject:
Reply with quote

THank You for your response.
@ PeterHolland
It is still giving the same when I used the datatype as S9(9) BINARY.

@ Mathiv Anan
I don't know the correct datatype of Index ,so we cannot use that statement.

Thanks
Back to top
View user's profile Send private message
Sambhaji

Active Member


Joined: 16 Feb 2007
Posts: 838
Location: Pune, India

PostPosted: Tue Feb 02, 2010 2:35 pm    Post subject:
Reply with quote

rgupta wrote:
@ Mathiv Anan
I don't know the correct datatype of Index ,so we cannot use that statement.

Have you tried it?
It works. Define SAVE-INDEX as normal display numeric.
Back to top
View user's profile Send private message
rgupta71

New User


Joined: 21 Jun 2009
Posts: 60
Location: Indore

PostPosted: Tue Feb 02, 2010 2:47 pm    Post subject:
Reply with quote

Thanks Sambhaji for your response.
I defined 01 SAVE-INDEX as PIC S9(9) BINARY and then I did Set SAVE-INDEX to INDEX. It worked.
Back to top
View user's profile Send private message
Terry Heinze

Senior Member


Joined: 14 Jul 2008
Posts: 1054
Location: Richfield, MN, USA

PostPosted: Tue Feb 02, 2010 6:45 pm    Post subject:
Reply with quote

rgupta71,
At 2:42 AM it DID NOT work and at 3:17 AM, it DID work? Am I missing something?
Back to top
View user's profile Send private message
rgupta71

New User


Joined: 21 Jun 2009
Posts: 60
Location: Indore

PostPosted: Tue Feb 02, 2010 6:57 pm    Post subject:
Reply with quote

@ Terry Heinze
Initially I was using MOVE statement to save the Index variable in a working storage variable instead of using SET.Also at 2:42 I was not knowing the datatype of SAVE-INDEX.Sambhaji and PeterHolland mentioned the datatype which helped me solve this issue.
Mathiv Anan gave me the correct statement to use SET instead of MOVE.

Thanks everyone.
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 16
Location: New York

PostPosted: Fri Feb 05, 2010 12:32 am    Post subject: Reply to: What is Data Type of Index of the Array.
Reply with quote

10 ACTIVITY-TABLE-AREA.
15 ACTIVITY-TABLE OCCURS 1 TO 5000 TIMES
DEPENDING ON TBL-CTR
INDEXED BY INDEX.

The word INDEX is a COBOL Reserved word -- CHANGE IT to something else like INDEX-A.

If you create an INDEX WORKING-STORAGE field that is not associated with a TABLE -- you usually code it like this
01 ws-index-fld usage INDEX.

SO DO NOT USE INDEX AS A DATA NAME
Back to top
View user's profile Send private message
rgupta71

New User


Joined: 21 Jun 2009
Posts: 60
Location: Indore

PostPosted: Sat Feb 06, 2010 10:48 am    Post subject: Reply to: What is Data Type of Index of the Array.
Reply with quote

Thank You ridgewalker58.

I will keep that in my mind.
Back to top
View user's profile Send private message
mdtanweer

New User


Joined: 26 Mar 2009
Posts: 3
Location: Bangalore

PostPosted: Thu Feb 11, 2010 5:14 pm    Post subject:
Reply with quote

Hi Experts,

I have an array indexed by WT-INDEX. Please tell me the picutre claus i need to give for this WT-INDEX variable.
Back to top
View user's profile Send private message
Mathiv Anan

New User


Joined: 23 Jul 2008
Posts: 94
Location: India

PostPosted: Thu Feb 11, 2010 5:32 pm    Post subject: Reply to: What is Data Type of Index of the Array.
Reply with quote

You can get plenty of information by searching this forum.

Also, refer to the sections 1.8.1.7, 1.8.1.8 and 1.8.1.9 in below manual link.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGY3LR50/CCONTENTS?
Back to top
View user's profile Send private message
Anuj Dhawan

Global Moderator


Joined: 22 Apr 2006
Posts: 4081
Location: Mumbai, India

PostPosted: Thu Feb 11, 2010 5:35 pm    Post subject:
Reply with quote

There is a link to manuals at the top of the page. Find the COBOL Language Reference and Programming Guide manuals and read the information in them about OCCURS/INDEXes.
Back to top
View user's profile Send private message
Bill O'Boyle

Active Member


Joined: 14 Jan 2008
Posts: 991
Location: South Carolina, USA

PostPosted: Thu Feb 11, 2010 5:39 pm    Post subject: Reply to: What is Data Type of Index of the Array.
Reply with quote

Indexes (properly plural as Indices) don't have a PICTURE clause. Internally, they are represented as aligned binary-fullwords and are built buy the compiler and stored in the TGT.

If you define an INDEX in WORKING-STORAGE, it's as easy as -

03 WS-INDEX INDEX.

You don't specify a VALUE clause.

Indices in WS can only be SET to other Indices associated with a given array and are used primarily as a work-area. Although not "quite" as efficient, binary-fullwords in WS can also be specified as an index work-area and are more popular with programmers than WS indices.

I've rarely used WS Indices and use WS binary-fullwords instead.

Bill
Back to top
View user's profile Send private message
mdtanweer

New User


Joined: 26 Mar 2009
Posts: 3
Location: Bangalore

PostPosted: Mon Feb 15, 2010 4:02 pm    Post subject:
Reply with quote

Hi Experts,
I declared 05 save-index pic s9(9) binary and used set save-index to index. Then i tried: display save-index but its not displaying the value rather its displaying only blanks. Could you please help
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 HoursGoto page 1, 2  Next
Page 1 of 2