GeekInterview.com
Series: Subject: Topic:
Question: 182 of 232

What is the difference between a subscript and an index in a table definition?

A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decremented by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program's working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.
Asked by: Interview Candidate | Asked on: Sep 29th, 2004
Showing Answers 1 - 4 of 4 Answers
narendra

Answered On : Mar 3rd, 2006

subscript tells the occurance of a table.where as index tells the displacement of the table. subscript is a working storage variale where as index is not a working storage variable. never use both index and subscript combinely

Yes  1 User has rated as useful.
  
Login to rate this answer.

We can use up by 1/down by 1 in Index but in Subscript we should keeping adding 1.

  
Login to rate this answer.
ramesh4greek

Answered On : Jun 11th, 2010

View all answers by ramesh4greek

SUBSCRIPT: No. of occurences is called Subscript.
INDEX: The disposition of the element.
Index can be used in Table data searching and Sorting but Subscript won't be useful for the above.

  
Login to rate this answer.
vjjammi

Answered On : Aug 7th, 2010

View all answers by vjjammi

An Index is the value of OFFSET or DISPLACEMENT from the starting of the array. The index is defined as part of the occurs clause in the definition of the array as shown below.

01 WS-TABLE-ARRAY.
02 WS-TEMP-ARRAY   OCCURS  20 TIMES  INDEXED BY WS-INDX.
     05 WS-TEMP-1     PIC X(01) value spaces.
     05 WS-TEMP-2     PIC X(02) value spaces.

*Note : WS-INDX is the index in this case.

The processing of an INDEX is much faster than the usage of a subscript.

The SET command can be used on an INDEX.

An subscript is the occurance of the element in the table and the subscript is declared explicitly as a working storage variable. The processing time for subscript is more.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.