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
 

 

What is Data Type of Index of the Array.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
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

PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
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

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

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

Active User


Joined: 21 Jun 2009
Posts: 160
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
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

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

Active User


Joined: 21 Jun 2009
Posts: 160
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

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
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

Active User


Joined: 21 Jun 2009
Posts: 160
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: 51
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

Active User


Joined: 21 Jun 2009
Posts: 160
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: 6
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

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

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

Senior Member


Joined: 22 Apr 2006
Posts: 6258
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

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, 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: 6
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
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Mon Feb 15, 2010 4:25 pm    Post subject: Reply to: What is Data Type of Index of the Array.
Reply with quote

Hi Mohammad,

Posting your code would be helpful to get a solution.
Back to top
View user's profile Send private message
mdtanweer

New User


Joined: 26 Mar 2009
Posts: 6
Location: Bangalore

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

@ Mathi

My code is like this:
declaration:-
05 SAVE-INDEX PIC S9(9) BINARY

SET SAVE-INDEX TO INDEX (here INDEX is the index of an array)
DISPLAY SAVE-INDEX
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Feb 20, 2010 8:40 pm    Post subject:
Reply with quote

Hi Mohammad,

To display the occurence # of the table field pointed to by an iINDEX you have to define a numeric filed (zoned decimal), then:

SET numeric field TO INDEX, then DISPLAY numerc field.

BTW, if I recall correctly, the INDEX contains the offset into the table of the data item referenced by the INDEX, not the occurence#. That's why you have to execute the SET - to do the conversion.
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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


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