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 

Binary Search Problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Mar 13, 2006 10:39 am    Post subject: Reply with quote

treks02,

Some of the older compilers may not allow look up on multiple fields. Try this code. Hopefully it should solve the error.


Code:
 
01 MY-TABLE.                                               
   03 ELEMENT-LIST  OCCURS  0 TO 20000,                   
                    DEPENDING ON  REC-LENGTH               
                    ASCENDING KEY IS TABLE-LOOKUP-KEY     
                    INDEXED BY IDX.                       
       05 TABLE-LOOKUP-KEY.                               
          10 ELEMENT-1                  PIC X(2).         
          10 ELEMENT-2                  PIC X(2).         
          10 ELEMENT-3                  PIC X(2).         
       05 ELEMENT-4                     PIC X(2).         
       05 ELEMENT-5                     PIC X(1).         
       05 ELEMENT-6                     PIC X(15).         
       05 ELEMENT-7                     PIC X(2).         
       05 ELEMENT-8                     PIC X(1).         
       05 ELEMENT-9                     PIC X(15).     

SEARCH ALL ELEMENT-LIST                           
         AT END                                   
            SET NO-REC-FOUND      TO TRUE         
       WHEN TABLE-LOOKUP-KEY(IDX) =  'XXYYZZ'     
            MOVE ELEMENT-1(IDX)   TO WV-TEMP-VAR1
            MOVE ELEMENT-2(IDX)   TO WV-TEMP-VAR2
            MOVE ELEMENT-3(IDX)   TO WV-TEMP-VAR3
END-SEARCH.                                           


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
treks02
Beginner


Joined: 08 Mar 2006
Posts: 15
Topics: 3

PostPosted: Mon Mar 13, 2006 10:35 pm    Post subject: Reply with quote

hi kolusu,

thanks for the help, i now have only 1 severe error.

Code:

IGYPS2213-S   "NO-REC-FOUND" was reference modified and reference modification is not allowed in this context.  The statement was discarded.



what could this be?
Back to top
View user's profile Send private message
treks02
Beginner


Joined: 08 Mar 2006
Posts: 15
Topics: 3

PostPosted: Mon Mar 13, 2006 11:01 pm    Post subject: Reply with quote

hi again,

i saw this in the internet:
http://docs.hp.com/en/65/books/emsynt.htm
Quote:

0366 Variable length delimiter not allowed
You cannot use a reference modified item or a group containing an OCCURS ... DEPENDING ON clause in this context.

Replace the reference modified item, or specify a valid item in the OCCURS DEPENDING ON clause.


could this be the problem?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Mar 14, 2006 8:55 am    Post subject: Reply with quote

treks02,

How is NO-REC-FOUND defined? Also what version of cobol are you using? you can find that as the first line of your compile listing.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
treks02
Beginner


Joined: 08 Mar 2006
Posts: 15
Topics: 3

PostPosted: Tue Mar 14, 2006 11:59 pm    Post subject: Reply with quote

kolusu wrote:
treks02,

How is NO-REC-FOUND defined? Also what version of cobol are you using? you can find that as the first line of your compile listing.

Kolusu


88 NO-REC-FOUND PIC X

PP 5655-G53 IBM Enterprise COBOL for z/OS and OS/390 3.2.1

I think this causes the problem...
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Mar 15, 2006 4:00 am    Post subject: Reply with quote

Are you sure your error message is pointing to the line in SEARCH statement ?

Anyway, code 88 conditions as follows:
Code:

05  W000-Flg-Valid                Pic X(01) .
    88 88-Valid-Pass              Value 'Y' .
    88 88-Valid-Fail              Value 'N' .

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
treks02
Beginner


Joined: 08 Mar 2006
Posts: 15
Topics: 3

PostPosted: Wed Mar 15, 2006 6:59 am    Post subject: Reply with quote

Cogito-Ergo-Sum wrote:
Are you sure your error message is pointing to the line in SEARCH statement ?

Anyway, code 88 conditions as follows:
Code:

05  W000-Flg-Valid                Pic X(01) .
    88 88-Valid-Pass              Value 'Y' .
    88 88-Valid-Fail              Value 'N' .


hi Cogito-Ergo-Sum,

sori that was a typo error
I have coded NO-REC-FOUND the same way as you did.

Code:

05  WF-REC-FLG                Pic X(01) .
    88 REC-FOUND              Value 'Y' .
    88 NO-REC-FOUND         Value 'N' .


I dont know what could be the reason but wheN i tried to use

Code:

MOVE 'N' TO WF-REC-FLG     


THE ERROR DISAPPEARED. THANKS!
Back to top
View user's profile Send private message
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Thu Jul 27, 2006 6:31 am    Post subject: Reply with quote

I have a table with < 100 records.
Which Search method will be better. SEARCH or SEARCH ALL.
whats the criteria to decide SEARCH/SEARCH ALL.
pls let me know if u have any links for it.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 27, 2006 9:59 am    Post subject: Reply with quote

vak255 wrote:
I have a table with < 100 records.
Which Search method will be better. SEARCH or SEARCH ALL.
whats the criteria to decide SEARCH/SEARCH ALL.
pls let me know if u have any links for it.


For a table of that size , It does NOT make any difference. SEARCH , PERFORM VARYING and SEARCH ALL will be the same for small tables. SEARCH ALL is effective for large tables (atleast 5k ) to notice any difference in the performance.

For large SORTED tables SEARCH ALL will be better. For such tables using a binary search (SEARCH ALL) can be 18% faster than using a sequential search (SEARCH)

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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
Goto page Previous  1, 2
Page 2 of 2

 
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