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.

Showing Answers 1 - 4 of 4 Answers

narendra

  • 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

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.

  Was this answer useful?  Yes

vjjammi

  • Aug 7th, 2010
 

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.

  Was this answer useful?  Yes

Give your answer:

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

Answer Question

Click here to Login / Register your free account


 
Send   Reset

 

Related Answered Questions

 

Related Open Questions