---
title: "COBOL: SEARCH Vs PERFORM Which is Better"
description: "You can search an array using SEARCH or PERFORM in COBOL. The logic of which one to choose depends on two conditions. Those are index and subscripts. Read more."
url: https://srinimf.com/2016/03/01/searching-cobol-table-with-search-and-without-serach/
date: 2016-03-01
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/03/pexels-photo-4050318.jpeg?fit=1880%2C1253&ssl=1
categories: ["COBOL"]
tags: ["COBOL Searching Internal Table"]
type: post
lang: en
---

# COBOL: SEARCH Vs PERFORM Which is Better

## Search Table using PERFORM

PERFORM statement you can use when you defined an array with a subscript.

Related[Search Vs Search all in COBOL: Top Differences](https://srinimf.com/2015/10/02/cobol-search-and-search-all-differences/)

### **Method-1**

```
PERFORM P200-READ-SALES-FILE.
MOVE '*** NO PART DESCRIPTION' TO RPT-DTL-PART-DESC.
[PERFORM VARYING](https://srinimf.com/2015/07/24/mainframe-cobol-occurs-indexed-byusage-is-index-2-of-2/) WS-SUB FROM 1 BY 1 UNTIL (WS-SUB > WS-TBL-MAX)
OR (IN-PRT-NBR = PART-NBR (WS-SUB))
IF IN-PRT-NBR = PART-NBR (WS-SUB)
   MOVE PART-DESC                  TO RPT-DTL-PART-DESC 
END-IF 
END-PERFORM.
```

Related[COBOL: Indexed By Vs Subscript key Differences](https://srinimf.com/2015/07/21/5-key-differences-of-index-and-subscript-for-cobol-programmers/)

## Search Table using SEARCH statement

### **Method-2**

You can use SEARCH logic when your Table defined with an index.

```
PERFORM P200-READ-SALES-FILE.
SET WS-INDX TO 1.
SEARCH PART-TABLE
AT END MOVE '*** NO PART DESCRIPTION' TO RPT-DTL-PART-DESC
WHEN IN-PRT-NBR = PART-NBR (WS-INDX)
MOVE PART-DESC TO RPT-DTL-PART-DESC END-SEARCH.
```

Related Posts

- [![How to Find Databricks Job Status, Owner, and Active Runs Fast](https://i0.wp.com/srinimf.com/wp-content/uploads/2026/10/pexels-photo-30972899.jpeg?resize=867%2C1300&ssl=1)](https://srinimf.com/2026/10/17/databricks-find-job-status/) ## [How to Find Databricks Job Status, Owner, and Active Runs Fast](https://srinimf.com/2026/10/17/databricks-find-job-status/) Need to audit Databricks workflows? Step-by-step guide to tracking job creators, service principal run identities, and current execution status in Databricks.

### 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%2F2016%2F03%2F01%2Fsearching-cobol-table-with-search-and-without-serach%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F03%2Fpexels-photo-4050318.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=COBOL%3A%20SEARCH%20Vs%20PERFORM%20Which%20is%20Better)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/03/01/searching-cobol-table-with-search-and-without-serach/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/03/01/searching-cobol-table-with-search-and-without-serach/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/03/01/searching-cobol-table-with-search-and-without-serach/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/03/01/searching-cobol-table-with-search-and-without-serach/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%3A%20SEARCH%20Vs%20PERFORM%20Which%20is%20Better&body=https%3A%2F%2Fsrinimf.com%2F2016%2F03%2F01%2Fsearching-cobol-table-with-search-and-without-serach%2F&share=email)
-

### Like this:

Like Loading…
