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
 
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: 1191
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: 1191
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
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm

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