---
title: "COBOL: How to Use INDEXED BY Clause"
description: "COBOL Tricky example on OCCURS and Indexed By explained"
url: https://srinimf.com/2011/06/27/cobol-index-and-subscript/
date: 2011-06-27
modified: 2026-10-05
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2020/04/cobol-occurs-and-indexed-by-example.jpg?fit=1200%2C700&ssl=1
categories: ["COBOL"]
tags: ["COBOL Index", "Subscript"]
type: post
lang: en
---

# COBOL: How to Use INDEXED BY Clause

Can you pass an Index to another COBOL Program – via the [LINKAGE SECTION](https://srinimf.com/2015/02/17/passing-data-from-jcl-to-cobol/)?
No. Since INDEX is not a working storage area, an Index is maintained by the System. Indexes you cannot pass to another program. Subscripts you can pass. Because a subscript has a [working storage definition](https://srinimf.com/2015/07/21/5-key-differences-of-index-and-subscript-for-cobol-programmers/). You can pass a Subscript to another COBOL Program.

![subscript and index in cobo](https://i0.wp.com/srinimf.com/wp-content/uploads/2011/06/pexels-photo-4373456.jpeg?resize=867%2C1300&ssl=1)*Photo by jan valle on [Pexels.com](https://www.pexels.com/photo/pondering-vendor-in-casual-outfit-in-book-shop-4373456/)*

Table of contents

1. [COBOL Indexed By Best Example](https://srinimf.com/2011/06/27/cobol-index-and-subscript/#cobol-indexed-by-best-example)
2. [The Code is Explained](https://srinimf.com/2011/06/27/cobol-index-and-subscript/#the-code-is-explained)

## COBOL Indexed By Best Example

```
05  A-TABLE.                                   
    10  A-TABLE-LIST OCCURS 10 TIMES INDEXED BY A-IDX. 

        15  FILLER              PIC X(7) VALUE '<TEST>'. 
        15  A-LIST-VALUE        PIC X(30).                
        15  FILLER              PIC X(8) VALUE '</TEST>'.
```

The next he did as below:

```
SET A-IDX  to 1.
MOVE 'XYZ' to A-LIST-VALUE(A-IDX).
```

The index value is set to ‘1’. The value you can [increment or decrement](https://srinimf.com/2015/07/24/mainframe-cobol-occurs-indexed-byusage-is-index-2-of-2/) using ‘UP’ or ‘DOWN” statements and PERFORM statements. [Here is helpful example.](https://www.ibm.com/docs/en/cobol-zos/6.3?topic=table-indexing)

## The Code is Explained

>>> He displayed **A-TABLE-LIST **data, and it populates as ‘XYZ—————————‘

>>> The first field is FILLER, so all are spaces even if you define value.

>>> Second field, when you issue ‘MOVE’. The first 3 bytes occupy XYZ and the rest of all spaces

>>> The third field is FILLER, so all are spaces, even if you define value.

Related Posts

- [COBOL: Indexed By Vs Subscript key Differences](https://srinimf.com/2015/07/21/5-key-differences-of-index-and-subscript-for-cobol-programmers/)DateJuly 21, 2015
- [21 Tricky COBOL Interview Questions You Need](https://srinimf.com/2016/09/07/21-exclusive-cobol-2-questions-for-advanced-developers/)DateSeptember 7, 2016
- [COBOL: How to Use PERFORM Varying Correctly](https://srinimf.com/2015/07/24/mainframe-cobol-occurs-indexed-byusage-is-index-2-of-2/)DateJuly 24, 2015

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2011%2F06%2F27%2Fcobol-index-and-subscript%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fcobol-occurs-and-indexed-by-example.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=COBOL%3A%20How%20to%20Use%20INDEXED%20BY%20Clause)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2011/06/27/cobol-index-and-subscript/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2011/06/27/cobol-index-and-subscript/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2011/06/27/cobol-index-and-subscript/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2011/06/27/cobol-index-and-subscript/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%3A%20How%20to%20Use%20INDEXED%20BY%20Clause&body=https%3A%2F%2Fsrinimf.com%2F2011%2F06%2F27%2Fcobol-index-and-subscript%2F&share=email)
-

### Like this:

Like Loading…
