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
 

 

Difference between indexing and subscripting

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
sudha_shanmughan
Currently Banned

New User


Joined: 20 Feb 2007
Posts: 9
Location: chennai

PostPosted: Tue Feb 27, 2007 10:12 am    Post subject: Difference between indexing and subscripting
Reply with quote

Hi All,
what is the difference between indexing and subscripting?
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Tue Feb 27, 2007 10:24 am    Post subject:
Reply with quote

Hi There,

Subscript:Subscript represents occurrence # of the Table Entry. Subscript can be represented explicitly and implicitly. Explicitly means thru occurrence # of the table entry; implicitly means thru a data name. That data name should be defined as an independent item in the W-S Section. The most efficient definition of Subscript is Full-Word binary.

Index:Index is assigned to specific table thru INDEXED BY clause. Internally is represented by Index Register which is Full-Word binary. Specific index name can be used to reference a field from the table to which that index is assigned to index represents displacement value of the table entry from the beginning of the table.

Difference between index & subscript

1)Index represent displacement value of the table entry from the beginning of the table, subscript - occurrence # of the table entry.
2)An index can only be modified using PERFORM, SEARCH & SET
But we can modify subscript by ADD , SUBTRACT COMPUTE
statements also.
3)Need to have index for a table in order to use SEARCH, SEARCH ALL Cobol statements
Back to top
View user's profile Send private message
kshalini

New User


Joined: 20 Feb 2007
Posts: 8
Location: Banglore

PostPosted: Mon Mar 12, 2007 3:43 pm    Post subject: hi
Reply with quote

Can somebody explain with soem example its not very clear from above reply
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Mar 12, 2007 3:57 pm    Post subject:
Reply with quote

Hi Kshalini,

Hi there,

Subscript:Here it declare WS-TABLE-SUBSCRIPT is used as subscript.
Which we need to declare explicitly in working storage & we can directly do any arithmetic operation on it

Code:
01  WS-TABLE.
     05  WS-TABLE-ENTRY PIC X(10) OCCURS 10 TIMES.
     05  WS-TABLE-SUBSCRIPT   PIC S9(3) COMP-3.


Code:
    MOVE 5     TO WS-TABLE-SUBSCRIPT.
     DISPLAY WS-TABLE-ENTRY(WS-TABLE-SUBSCRIPT).
(or)
     DISPLAY WS-TABLE-ENTRY(5).


Index:Here TEST-TAB is indexed by INDX-1 index.We need not to declare it in working storage.


Code:
01  TEST-TABLE.                                         
    05  TEST-TAB                     OCCURS 10 TIMES   
                                     INDEXED BY INDX-1.
        10  TEST-DAT1                PIC X.             
        10  TEST-DAT2                PIC X.             
                                                       
 
To reference a particular element in table use SET clause

Code:


SET INDX-1    TO +5       
DISPLAY  TEST-DAT1(INDX-1)


Hope it is clear now
Back to top
View user's profile Send private message
abel
Warnings : 1

New User


Joined: 31 May 2006
Posts: 5

PostPosted: Tue Mar 27, 2007 11:56 am    Post subject: Re: Difference between indexing and subscripting
Reply with quote

Can you explain how does memory allocated for Subscript and Index
because in index we don't give any picture value
and how does sub and indes varies in calling suppose ab(I).
Back to top
View user's profile Send private message
kshalini

New User


Joined: 20 Feb 2007
Posts: 8
Location: Banglore

PostPosted: Tue Mar 27, 2007 1:29 pm    Post subject:
Reply with quote

Thanks
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
No new posts Difference space showed for TS and it... autobox DB2 1 Thu Apr 14, 2016 1:07 pm
No new posts Difference Between CICS WebSupport an... sachinji84 CICS 1 Mon Mar 07, 2016 7:25 pm
No new posts Difference between -180 and -181 with... deepak_shrivastava DB2 4 Wed Jan 06, 2016 10:00 am


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