IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Difference between indexing and subscripting


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Tue Feb 27, 2007 10:24 am
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
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: 1208
Location: Bangalore,India

PostPosted: Mon Mar 12, 2007 3:57 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts What is the difference between Taskty... Compuware & Other Tools 2
No new posts array indexing PL/I & Assembler 4
No new posts Difference between VALIDPROC and CHEC... DB2 3
Search our Forums:

Back to Top