Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Position of index when sequential search in not

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

New User


Joined: 29 Sep 2008
Posts: 6
Location: United Kingdom

PostPosted: Tue Dec 29, 2009 11:49 am    Post subject: Position of index when sequential search in not
Reply with quote

Hi,
I have a query related to sequential search in COBOL.
What would be the position on index when a sequential search is not successful.
Is it the last position ?
n+1 where n is the last position where data in stored in a table
or n.
Ex - A table with OCCURS 10 INDEXED BY I.
Suppose there is data in 5 positions.
If search is not successful the position of index is 10,6,5. I read somewhere that it is unpredictable.
Please help.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8201
Location: Dubuque, Iowa, USA

PostPosted: Tue Dec 29, 2009 4:31 pm    Post subject:
Reply with quote

The COBOL Language Reference (manuals link at the top of the page), section 6.2.32.1 on sequential SEARCH, is quite clear:
Quote:
If the end of the table is reached (that is, the value of the incremented index is greater than the highest possible occurrence number) without the WHEN condition being satisfied, the search is terminated.
In other words, the value will be 11 for your example.

Please note that the actual number of elements you've loaded into the table has no bearing upon the SEARCH verb. Only the defined number of elements (10 in your example) matters -- the fact that you've loaded only 5 elements means that you're comparing unknown values for the last 5 search tests (possibly LOW-VALUES, possibly something else).

If a BINARY search fails, the index value will be unpredictable. However, if a SEQUENTIAL search fails the index value is known.
Back to top
View user's profile Send private message
peyush

New User


Joined: 29 Sep 2008
Posts: 6
Location: United Kingdom

PostPosted: Tue Dec 29, 2009 5:41 pm    Post subject:
Reply with quote

Thanks for the response.
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 TBSARG - Deleting the search criteria... ISPFHerc TSO/ISPF 5 Thu Dec 14, 2017 8:18 am
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us