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: 7251

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: 7251

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 How to display value of an exit param... lind sh CICS 2 Sun Oct 09, 2016 12:28 pm
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm
No new posts SORT - E15 and E35 using same user ex... Abhi Nature DFSORT/ICETOOL 12 Mon Oct 03, 2016 4:33 pm
No new posts How to use my exit program. lind sh CICS 1 Tue Sep 13, 2016 1:54 pm
No new posts User exit in COBOL programs ganasrinivasan PL/I & Assembler 0 Thu Aug 18, 2016 12:48 pm


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