Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Exit the search when the first hit is found

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
preethan
Warnings : 1

New User


Joined: 15 Dec 2008
Posts: 33
Location: Chennai

PostPosted: Wed Oct 26, 2011 3:24 am    Post subject: Exit the search when the first hit is found
Reply with quote

May be this is a silly question. But I am not getting a easy solution for it.

I have two rows in an internal table. Let A,B,C be the field names

A B C

3 5 3
4 2 1
3 5 3

Now I'm using search variable in cobol. I am searching for the field 'A'. Lets assume that I'm searching if the field A has value as 3. There are two rows here. I want to exit the search when the first hit is found. I don't want the search to be performed even after getting hold of the first row. In simple terms I need to exit the search finding the first hit.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Oct 26, 2011 3:38 am    Post subject: Reply to: Help in Search
Reply with quote

Have you tried to code it? What happened? How do you interpret what the manual says?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Oct 26, 2011 3:54 am    Post subject:
Reply with quote

Do a sequential search not a "search all".
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Oct 26, 2011 4:13 am    Post subject: Reply to: Help in Search
Reply with quote

The thing is, as Craq has said, if you do a plain SEARCH it will do what you want, ie only find the first "5" and then stop searching.

This is what it says in the manual. If you are not getting that behaviour, then we need to see your code (definitions of all the data and the SEARCH statement itself).

If you are having a problem, the easiest error to make is not to set up the initial condition for the search. Check what it says in the manual, check against your code.

If you are still having a problem, post the stuff requested (in the Code tags, please) and we can see what we can do.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 26, 2011 7:45 am    Post subject:
Reply with quote

Hello,

Quote:
I have two rows in an internal table. Let A,B,C be the field names

A B C

3 5 3
4 2 1
3 5 3
I see 3 "rows".

How have you set up the SEARCH? The array?

At the top of the page is a link t "IBM Manuals". The first set of manuals id for COBOL. Look at the Language Reference for your level of COBOL.

If you find something that is not clear, post what you found and your doubt. Someone will be able to clarify.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts EXIT or RETURN cvnlynn CLIST & REXX 16 Wed Jul 19, 2017 2:50 am
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Row not found Sql error GaganGarg DB2 7 Tue Mar 07, 2017 6:29 am
No new posts How to display value of an exit param... lind sh CICS 2 Sun Oct 09, 2016 12:28 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us