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
 
Query : About Index and Subscripts

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

New User


Joined: 23 Dec 2005
Posts: 1
Location: Pune

PostPosted: Fri Dec 23, 2005 1:44 am    Post subject: Query : About Index and Subscripts
Reply with quote

Hi,

I will be very thankful if any one could let me know the difference between Subscript and Index in COBOL. How do we use both and what is the difference between the declarations of both.
Back to top
View user's profile Send private message

rskumar

New User


Joined: 21 Nov 2005
Posts: 35
Location: chennai

PostPosted: Fri Dec 23, 2005 8:23 am    Post subject: index n subscript
Reply with quote

hi,
Index refers to the position of the array element in the array and subscript refers to the number of occurences of the element in an array.
As you know that index should be given in an array i.e., here in cobol, a table.... we use occurs clause in 02 level variable. there we have to specify the index name. i'll reply for subscript later.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Dec 23, 2005 10:09 am    Post subject: Re: Query : About Index and Subscripts
Reply with quote

ritesh,

INDEX & SUBSCRIPTS, both are used to access ARRAYS/TABLES in COBOL.

INDEX refers to the ARRAY Members by the displacement, but SUBSCRIPTS refer to the ARRAY Members using occurances.

For EX.

INDEX:
Code:
03 TEMP-VAL PIC X(5) OCCURS 10 TIMES INDEXED BY TEMPIDX.


Now you refer this as TEMP-VAL(TEMPIDX). And TEMPIDX cant be modified using any arithmetic opeartion.

SUBSCRIPT:
Its a normal cobol variable, which can be used to access ARRAY based on position number.

Code:
77 TEMP-VAL PIC X(5) OCCURS 10 TIMES.
77 TEMP-SUBS PIC 9(2).

MOVE 3 to TEMP-SUBS.
DISPLAY TEMP-VAL(TEMP-SUBS).

Now you can modify TEMP-SUBS using any arithmetic operations too.

Regards,

Priyesh.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Fri Dec 23, 2005 5:17 pm    Post subject:
Reply with quote

The same question was asked few days before. You could have done a search before posting your query.
Back to top
View user's profile Send private message
gcchowdary
Warnings : 1

New User


Joined: 26 Dec 2005
Posts: 18
Location: India

PostPosted: Mon Dec 26, 2005 7:41 pm    Post subject: hi
Reply with quote

hi piyush
Back to top
View user's profile Send private message
gcchowdary
Warnings : 1

New User


Joined: 26 Dec 2005
Posts: 18
Location: India

PostPosted: Mon Dec 26, 2005 7:43 pm    Post subject: hi piyush
Reply with quote

Can we use OCCURS in 77 level number...
i think no , please let me know if i am wrong...
Back to top
View user's profile Send private message
jcbhimani

New User


Joined: 30 Nov 2006
Posts: 12
Location: Ahmedabad

PostPosted: Thu Nov 30, 2006 8:48 pm    Post subject:
Reply with quote

We cann't use OCCURS clause at 01,66,77 or 88 level.
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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
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 Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am

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