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
 

 

Search all is giving less records as compare to search
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Tue Nov 03, 2009 12:21 am    Post subject: Search all is giving less records as compare to search
Reply with quote

In a Cobol program, I am loading a sorted file that has around 100000 records first into an array defined for "search" and then an array defined for "search all". Then I am reading a file and searching a key record into both defined array separately. However, after searching the record into array defined for "search all" is giving around 1 % less records as compare to the array defined for "search". Other records are same. I think this should not happen and in both the cases I should get same file.

Please advice.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Nov 03, 2009 12:30 am    Post subject:
Reply with quote

Do you initialize the "SEARCH ALL" file? If so, what do you initialize it to? How many table entries are there and how many are loaded from the file?

The COBOL SEARCH ALL verb mandates the table be sorted into ascending sequence. If your table is larger than the number of entries you loaded from the file, you must set the remaining entries to some value larger than the highest key value loaded (typically HIGH-VALUES is used) or the SEARCH ALL verb may not always return the correct results.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Nov 03, 2009 1:15 am    Post subject:
Reply with quote

Actually, the table being referenced by a 'SEARCH ALL' can be in either ASCENDING KEY or DESCENDING KEY sequence. If ASCENDING KEY sequence, unused entries are typically filled with HIGH-VALUES, as Robert indicated. If DESCENDING KEY sequence, the unused entries are typically filled with LOW-VALUES.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 03, 2009 1:28 am    Post subject:
Reply with quote

Pankaj,
what is the data layout definition of your two COBOL internal tables?

you are correct, results from both 'tables' should be the same.

in fact, the processing time should be less for the SEARCH ALL (binary search) than for the SEARCH.

might as well provide your code for both 'searches'.

you have something wrong, otherwise the results would be the same.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Nov 03, 2009 1:33 am    Post subject:
Reply with quote

Ronald, you're right -- I forgot about the descending key feature and I definitely should have mentioned it.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue Nov 03, 2009 8:53 am    Post subject:
Reply with quote

Pankaj,
Are you saying that the total number of occurrences of the "search all" table is about 1% less than the total number of occurrences of the "search" table? Or are you saying that you get fewer "hits" during the SEARCH ALL than during the SEARCH? Please clarify. Also, please answer the questions by the dinosauer and Robert.
Back to top
View user's profile Send private message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Tue Nov 03, 2009 9:51 am    Post subject:
Reply with quote

Robert Sample wrote:
Do you initialize the "SEARCH ALL" file? If so, what do you initialize it to? How many table entries are there and how many are loaded from the file?

The COBOL SEARCH ALL verb mandates the table be sorted into ascending sequence. If your table is larger than the number of entries you loaded from the file, you must set the remaining entries to some value larger than the highest key value loaded (typically HIGH-VALUES is used) or the SEARCH ALL verb may not always return the correct results.


Yes, with SEARCH ALL verb, I am using sorted input file.
Can you please explain bit more this HIGH-VALUES thing.
Back to top
View user's profile Send private message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Tue Nov 03, 2009 9:55 am    Post subject:
Reply with quote

Terry Heinze wrote:
Pankaj,
Are you saying that the total number of occurrences of the "search all" table is about 1% less than the total number of occurrences of the "search" table? Or are you saying that you get fewer "hits" during the SEARCH ALL than during the SEARCH? Please clarify. Also, please answer the questions by the dinosauer and Robert.


Hi Terry,
I was saying that I got fewer "hits" during the SEARCH ALL than during the SEARCH.

Thanks
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: Tue Nov 03, 2009 9:59 am    Post subject:
Reply with quote

Hello,

Before loading the entries into the SEARCH ALL table, you need to move HIGH-VALUES to the entire array so that the "unused entries" at the end are in sequence.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue Nov 03, 2009 10:09 am    Post subject:
Reply with quote

As requested, we need to see the definitions of the tables, the code that loads them and the code that searches them. Please use BBCode (see FAQ).
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 03, 2009 2:39 pm    Post subject:
Reply with quote

ppandey07,

if you would use an ODO (occurs depending on)
  1. both your SEARCH instructions would execute faster
  2. you would not need to know all this esoteric stuff about initializing tables, etc...


Suggest you read the COBOL Application Programmers manual about COBOL internal tables;
which you obviously not done.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 03, 2009 4:50 pm    Post subject:
Reply with quote

delete by poster.
Back to top
View user's profile Send private message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Tue Nov 03, 2009 5:20 pm    Post subject:
Reply with quote

Terry Heinze wrote:
As requested, we need to see the definitions of the tables, the code that loads them and the code that searches them. Please use BBCode (see FAQ).


The way I am defining my table for "seach all" is :

< 01 WS-CES-TABLE.
05 WS-CES OCCURS 99999 TIMES ASCENDING KEY IS WS-CES-SORT-KEY
INDEXED BY CESX.
10 WS-CES-SORT-KEY.
15 WS-CES-POLICY PIC X(06).
15 WS-EMPLOY-ID PIC X(9).
15 WS-CES-FIRST-NAME PIC X(10).
15 WS-CES-BIRTH-DATE PIC 9(08).
15 WS-CES-RELATIONSHIP PIC X(02).
10 WS-CES-MED-PRISEC-IND PIC X(01).
10 WS-CES-START-DATE PIC X(08).
10 WS-CES-STOP-DATE PIC X(08). >



and I am using the "search all" verb as

<SEARCH ALL WS-CES
AT END
CONTINUE
WHEN WS-CES-SORT-KEY (CESX) = WS-COB2-SORT-KEY
PERFORM VARYING WS-SUB FROM 1 BY 1
UNTIL WS-SUB > COB2-LINE-COUNT

EVALUATE TRUE
WHEN
in evaluate checking few condtions and WS-COB2-SORT-KEY is the key field from file >

Can you please adivise if there is anything wrong.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Nov 03, 2009 5:42 pm    Post subject:
Reply with quote

Quote:
Can you please adivise if there is anything wrong.
Where's your code that verifies the table is loaded in ascending sequence by WS-CES-SORT-KEY? Where do you verify that you do not have any duplicates in WS-CES-SORT-KEY in the table? From the COBOL Language Reference manual:
Quote:
The results of a SEARCH ALL operation are predictable only when:

* The data in the table is ordered in ASCENDING KEY or DESCENDING KEY order

* The contents of the ASCENDING or DESCENDING keys specified in the WHEN clause provide a unique table reference.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue Nov 03, 2009 10:00 pm    Post subject:
Reply with quote

I asked for 5 things and to use BBCode. You have provided only 2 of the 5 and didn't use BBCode. You can't expect much help when you don't provide the information requested.
Back to top
View user's profile Send private message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Wed Nov 04, 2009 10:16 am    Post subject:
Reply with quote

Robert Sample wrote:
Quote:
Can you please adivise if there is anything wrong.
Where's your code that verifies the table is loaded in ascending sequence by WS-CES-SORT-KEY? Where do you verify that you do not have any duplicates in WS-CES-SORT-KEY in the table? From the COBOL Language Reference manual:
Quote:
The results of a SEARCH ALL operation are predictable only when:

* The data in the table is ordered in ASCENDING KEY or DESCENDING KEY order

* The contents of the ASCENDING or DESCENDING keys specified in the WHEN clause provide a unique table reference.


Hi all,

Thank you all!!! its working fine now...
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 Nov 04, 2009 10:22 am    Post subject: Reply to: Search all is giving less records as compare to se
Reply with quote

Good to hear it is working icon_smile.gif

What was the problem and what fixed it?

The answer may help someone with a similar problem one day.

d
Back to top
View user's profile Send private message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Wed Nov 04, 2009 10:36 am    Post subject: Re: Reply to: Search all is giving less records as compare t
Reply with quote

dick scherrer wrote:
Good to hear it is working icon_smile.gif

What was the problem and what fixed it?

The answer may help someone with a similar problem one day.

d



The input file that I was loading into table( defined with "search all") had some duplicate records. Thats why, I was getting small difference in output records.

Thanks all once again for your tips icon_biggrin.gif
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 Nov 04, 2009 8:27 pm    Post subject: Reply to: Search all is giving less records as compare to se
Reply with quote

Thanks for posting the solution icon_smile.gif

d
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Nov 05, 2009 12:30 am    Post subject: Reply to: Search all is giving less records as compare to se
Reply with quote

Keep in mind that your WS table is around 5MB.

I imagine you've defined it this large because of the unknown number of records on the file?

So (for example), if you only use 10% of this table, then you'd be wasting 4.5MB icon_eek.gif

Is this a VSAM (KSDS/ESDS) or sequential (Non-VSAM) flat-file?

Bill
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 5 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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