MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Different count in Search and Search All

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
viswanathan
Beginner


Joined: 17 Jan 2006
Posts: 26
Topics: 13

PostPosted: Fri Jul 03, 2009 8:54 am    Post subject: Different count in Search and Search All Reply with quote

I had asked to change the usage of SEARCH in the cobol program with SEARCH ALL.

Existing Code:
Code:

05  AB-SUB                  PIC S9(08)  COMP  VALUE +00001
05  AB-MAX                  PIC S9(08)  COMP  VALUE +30000
05  AB-TABLE.
    10  AB-ENTRY           OCCURS 30000 TIMES
                           INDEXED BY AB-IDX.
        15  AB-PRODUCT      PIC  X(03).
        15  AB-DESIGN       PIC  X(09).
        15  AB-SEC          PIC  X(09).
        15  AB-SECTOR       PIC  X(01).
        15  AB-INDUSTRY     PIC  9(02).

SET  AB-IDX       TO  1
SEARCH  AB-ENTRY
    WHEN FILE-SEC   =  AB-SEC   (AB-IDX)
       AND AB-PRODUCT (AB-IDX) = 'XXX'
       MOVE AB-SECTOR (AB-IDX) TO FILE-SECT
       MOVE AB-INDUSTRY(AB-IDX) TO FILE-INDU
       IF AB-SECTOR (AB-IDX)  =  'X'
       AND AB-INDUSTRY(AB-IDX) = AB
           ADD +1            TO COUNTER
           MOVE 13           TO FILE-SECTOR
           MOVE 4            TO FILE-AVG
           MOVE 2            TO FILE_DECK
       END-IF
    WHEN AB-MAX  =  AB-IDX
       NEXT SENTENCE
END-SEARCH


I changed this code as below:
Code:

05  AB-SUB                  PIC S9(08)  COMP  VALUE +00001
05  AB-MAX                  PIC S9(08)  COMP  VALUE +30000
05  AB-TABLE.
    10  AB-ENTRY           OCCURS 30000 TIMES
                           ASCENDING KEY IS AB-PRODUCT AB-SEC
                           INDEXED BY AB-IDX.
        15  AB-PRODUCT      PIC  X(03).
        15  AB-DESIGN       PIC  X(09).
        15  AB-SEC          PIC  X(09).
        15  AB-SECTOR       PIC  X(01).
        15  AB-INDUSTRY     PIC  9(02).


SEARCH  ALL AB-ENTRY
    WHEN  AB-SEC   (AB-IDX) = FILE-SEC 
       AND AB-PRODUCT (AB-IDX) = 'XXX'
       MOVE AB-SECTOR (AB-IDX) TO FILE-SECT
       MOVE AB-INDUSTRY(AB-IDX) TO FILE-INDU
       IF AB-SECTOR (AB-IDX)  =  'X'
       AND AB-INDUSTRY(AB-IDX) = AB
           ADD +1            TO COUNTER
           MOVE 13           TO FILE-SECTOR
           MOVE 4            TO FILE-AVG
           MOVE 2            TO FILE_DECK
       END-IF
END-SEARCH


Now the 'COUNTER' value is getting decreased after changing it to use SEARCH ALL option. Can any one please quickly help me out in this issue?

For the case of SEARCH, counter value is 2337
For the case of SEARCH ALL, counter value is 2332

This internal table AB-ENTRY is getting populated by using the cursor for the table. And for both the runs there is no change in the table values. Also, we have ordered the table based on the SEC and the product is same for all the rows in the table.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Jul 03, 2009 9:50 am    Post subject: Re: Different count in Search and Search All Reply with quote

what is AB as in AND AB-INDUSTRY(AB-IDX) = AB?
have you 30000 items?
With what did you initialize the Binary-Seached table before populating from your cursor?
Spaces? should have used High-Values.

and next time use code tags instead of coloring and size,
one of the moderators has edited your post for you.
you are lucky that I even responded; reading your post was a real pain.
It is only because it was such an easy problem.
_________________
Dick Brenholtz
American living in Varel, Germany


Last edited by dbzTHEdinosauer on Fri Jul 03, 2009 11:21 am; edited 2 times in total
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Jul 03, 2009 11:19 am    Post subject: Reply with quote

I imagine that your requirement is based on speeding up the module.
Using ODO would even make the Binary Search more effecient,
as well as rendering the initialization of the table unnecessary.

and of course, the reason that it was easy to determine the problem:
made the same mistake myself, once.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
viswanathan
Beginner


Joined: 17 Jan 2006
Posts: 26
Topics: 13

PostPosted: Mon Jul 06, 2009 12:00 am    Post subject: Reply with quote

Hi dbzTHEdinosauer,

Thanks for your reply. Hereafter, I will take care of posting the code with corresponding code tags.

I had initialized the binary table with LOW-VALUES. I shall try initializing with HIGH-VALUES and let you know the results.

'AND AB-INDUSTRY(AB-IDX) = AB' - I am not supposed to copy the exact code, so I have just pasted the syntax of what I am trying to achieve. It is to check whether the value 'AB' is present in the binary search table. Also, Binary Search internal table will have around 26500 records.


Thank you so much for the moderator for changing my post in more readable format.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Jul 06, 2009 4:20 am    Post subject: Reply with quote

read how a binary search is performed.
afterwards you will understand why init with low-values and not high-values is your problem,
and why and ODO would be faster to search.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group