IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Exit the search when the first hit is found


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Oct 26, 2011 3:38 am
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
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Oct 26, 2011 4:13 am
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

Moderator Emeritus


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

PostPosted: Wed Oct 26, 2011 7:45 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How I Found a Bug in a FORTRAN Compiler All Other Mainframe Topics 4
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Use of Perform Thru Exit COBOL Programming 6
No new posts user exit in IBM Infosphere Optim DB2 8
Search our Forums:

Back to Top