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
 

 

doubt regarding search all

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: doubt regarding search all
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    Post subject:
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    Post subject: Re: doubt regarding search all
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    Post subject:
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    Post subject: Re: doubt regarding search all
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    Post subject: Re: doubt regarding search all
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    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 Doubt in MFS abdulrafi IMS DB/DC 2 Fri Oct 21, 2016 3:09 pm
No new posts Search a Load Module sreekanth1984 TSO/ISPF 8 Tue Jun 07, 2016 8:45 pm
No new posts Copy one PDS to another PDS based on ... alluri12 JCL & VSAM 10 Tue Sep 29, 2015 8:10 pm
No new posts Doubt on GETMAIN, FREEMAIN behaviour Arunkumar Chandrasekaran CICS 3 Sun Aug 30, 2015 9:22 pm
No new posts Search and replace the key in the report V S Amarendra Reddy SYNCSORT 1 Thu Jul 09, 2015 7:41 pm


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