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

doubt regarding search all


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
srimsc_ibmmainframes

New User


Joined: 17 Feb 2004
Posts: 19
Location: pune

PostPosted: Mon Aug 22, 2005 2:58 pm
Reply with quote

While we work with SEARCH ALL how do we know that whether the table is in sorted order r not......?
Back to top
View user's profile Send private message
rahul_jot

New User


Joined: 17 Aug 2005
Posts: 22
Location: Pune

PostPosted: Tue Aug 23, 2005 11:42 am
Reply with quote

I think there is no way in SEARCH ALL to know whether the tables are sorted or not. We must sort the tables before using the SEARCH ALL options. Please correct me if I am wrong.
Back to top
View user's profile Send private message
sonalig

New User


Joined: 22 Aug 2005
Posts: 7
Location: India

PostPosted: Tue Aug 23, 2005 12:20 pm
Reply with quote

Hi,
While applying SEARCH ALL on a particular order, we MUST provide the KEY IS pharse in the table declaration itself. That means, COBOL expects the table to be sorted on some key-field in either ascending/descending order.

In case, we do not ensure that the table data is actually sorted, then SEARCH ALL will give unexpected results. So, its the programmer's responsiblity to make sure that the table is actually sorted in the order as per the table declaration.

If the table to be searched is only partially populated, the SEARCH ALL may not work correctly. If the table is ordered in ascending sequence then, to get the SEARCH ALL to function correctly, the unpopulated elements must be filled with HIGH-VALUES. If the table is in descending sequence, the unpopulated elements should be filled with LOW-VALUES.

Correct me if I'm wrong.
Thanks,
Sonali.
Back to top
View user's profile Send private message
sathish_rathinam

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Tue Aug 23, 2005 2:44 pm
Reply with quote

hi sonali,
could u tell me the syntax to declare for the key.......
the below syntax is correct or not,
occurs 1 to n times ascending\descending key is variable depending on identifier.
corret me.

regards
sathish
Back to top
View user's profile Send private message
nag
Warnings : 1

New User


Joined: 29 Jul 2005
Posts: 20

PostPosted: Tue Aug 23, 2005 8:58 pm
Reply with quote

hi buddies
can i know wat will b the actual will v get if the table is not in a sorted order and we have applied searchall
Back to top
View user's profile Send private message
sonalig

New User


Joined: 22 Aug 2005
Posts: 7
Location: India

PostPosted: Wed Aug 24, 2005 2:19 pm
Reply with quote

The syntax for KEY IS is:

OCCURS SmallBoundry#1 TO LargeBoundry#2 TIMES
DEPENDING ON Var#1
{ASCENDING/DESCENDING} KEY IS TableItem#
INDEXED BY IndexItem#.

Now, about the second question that "what will happen if we try to SEARCH on an unsorted table?".

Well, consider a situation, where your table is having single column say ItmNumber. You specify in the table declaration that it is sorted in ASCENDING order on KEY ItmNumber. Your data is not actually sorted, so it is containing following values:
ItmNumber(1) = 12
ItmNumber(2) = 2
ItmNumber(3) = 34
ItmNumber(4) = 17
ItmNumber(5) = 0

Now, you apply SEARCH ALL on this table, to search a value, say 17.
this value is present at 4th entry in the table.

Here, the main point to remember is that SEARCH ALL works as per Binary Search concept . So, internally, first ItmNumber(3) will be compared with 17. Since ItmNumber(3) i.e. 34 > 17, it'll discard the lower half section of the table and will start searching at the first half i.e. table location 1 & 2. It will now search at ItmNumber(2). Now, ItmNumber(2) i.e. 2 < 17. So, it'll conclude taht 17 is not present in the table and will return from the search and thus, you'll get incorrect result.

This is just a sample example given. In real life, you might get similar results for different permutations and combinations.

Thanks,
Sonali.
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 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 first column truncated in search result IBM Tools 13
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top