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

SEARCH ALL - WHEN statement ignored


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

New User


Joined: 24 Jul 2006
Posts: 18

PostPosted: Tue Mar 13, 2007 2:09 am
Reply with quote

Hi,

I have a table I'm doing a SEARCH ALL on and can't figure out why
the "WHEN" statement is apparently being ignored. Table is below.
I've put displays in prior to the WHEN statement and both the fields
in the WHEN stmt are populated and are a match. I put a display stmt
after the WHEN but it (display) doesn't show up. Been looking at this for
a while, I'm stumped.

Thanks,
J.
Code:


01  TABLE1.                                       
    05  WT-TABLE-CNT                       PIC 9(06) VALUE 0.
    05  TABLE1-PERIODS                                 
                                 OCCURS 500 TIMES           
                                 DEPENDING ON WT-TABLE-CNT   
                    ASCENDING KEY IS TABLE1-PROV-TYPE   
                                 INDEXED BY TABLE1-IDX.       
        10  TABLE1-PROV-TYPE        PIC X(02).         
        10  TABLE1-PROV-DESC        PIC X(41).         

05  WS-PROV-TYPE-SW     PIC X(01)  VALUE 'N'. 
    88 WS-PTYPE-FOUND              VALUE 'Y'. 
    88 WS-PTYPE-NOT-FOUND          VALUE 'N'. 

SET  TABLE1-IDX  TO 1
SEARCH ALL TABLE1-PERIODS                             
  AT END                                                   
     CONTINUE                                               
                                                           
WHEN TABLE1-PROV-TYPE  (TABLE1-IDX) = WH-PROV-TYPE
     SET WS-PTYPE-FOUND TO TRUE                       
                                                           
END-SEARCH                                                 
                                                           
CONTINUE.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 13, 2007 2:22 am
Reply with quote

Hello,

How have you verified that the table is loaded and is in the proper sequence?

Before working on your "SEARCH ALL", you might want to display the contents of the table from TABLE1-PERIODS(1) through whatever is the max for this run. What is in WT-TABLE-CNT?

Also, when you post your code, it is helpful is you post using the "Code" tag at the top of the replay panel.
Back to top
View user's profile Send private message
jtwohig

New User


Joined: 24 Jul 2006
Posts: 18

PostPosted: Tue Mar 13, 2007 2:33 am
Reply with quote

Thanks Dick !
I had put displays of the table field just prior to the WHEN statement and it showed it was populated. I didn't do a display, per se, of all of the table,I can try that. WT-TABLE-CNT holds the total recs loaded to the table. Will use "code" tag in future.
Thanks,
J.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Mar 13, 2007 2:38 am
Reply with quote

One key out of sequence will definitely mess things up, it is obvious that the search is "at end"ing prior to finding a match. Confirm the OCO counter and the sequence of the keys. also confirm the key and the search argument sizes are the same.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 13, 2007 3:46 am
Reply with quote

Hi J,

You're welcome icon_smile.gif

Just for testing, you might use SEARCH instead of SEARCH ALL. You might also set the index to 1 and go thru the table to verify if "this" TABLE1-PROV-TYPE is greater than the "previous" value. One out of sequence entry may cause the search to fail.

This may just be picky, but if the array can occur 500 times, i'd make the WT-TABLE-CNT (3) COMP-3 VALUE 0.

When i asked about WT-TABLE-CNT, i was looking for the current value. How many entries are there for this test?

You could look at the code that loads the table. It should "sequence check" as it loads the array.

Good luck - Waiting to hear from you icon_smile.gif
Back to top
View user's profile Send private message
jtwohig

New User


Joined: 24 Jul 2006
Posts: 18

PostPosted: Tue Mar 13, 2007 8:15 am
Reply with quote

Thanks William and Dick,

Let me check out some of the things you suggest.

Dick, you mentioned checking the code that loads the table. I'm not sure I know what you mean by a "sequence check" ?

Thanks,
J.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 13, 2007 8:26 am
Reply with quote

Hi J,

By that i mean to have some code that makes sure that each entry moved into the array has a "key" that is higher than the preceeding entry. For example, if there is a "GG" prov-type to be moved into the array, the previous entry must be "GF" or lower. Every entry to the table must be greater than the one before.

If you post the code that moves values to the array, it will be helpful.
Back to top
View user's profile Send private message
jtwohig

New User


Joined: 24 Jul 2006
Posts: 18

PostPosted: Tue Mar 13, 2007 5:15 pm
Reply with quote

Thanks Dick. I just now discovered my problem and I'm afraid it was a stupid one I can't believe I missed. In the table's "DEPENDING ON" phrase, I have "DEPENDING ON WT-TABLE-CNT". Well, in cloning code from another program I loaded the table adding to a field "WA-TABLE-CNT", so, naturally, WT-TABLE-CNT was always zero. Just shoot me !
Thanks again for your help.
J.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Mar 13, 2007 5:34 pm
Reply with quote

jtwohig wrote:
I just now discovered my problem and I'm afraid it was a stupid one I can't believe I missed.
Been there, done that, got the t-shirt to prove it...... icon_redface.gif
Back to top
View user's profile Send private message
jtwohig

New User


Joined: 24 Jul 2006
Posts: 18

PostPosted: Tue Mar 13, 2007 6:33 pm
Reply with quote

Thanks again William. Unfortunately, I'm sure this won't be the last time I'm chasing my tail...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 13, 2007 7:57 pm
Reply with quote

Hi J,

I hate when i do that. . . . icon_smile.gif

Glad you "caught" the tail. You got caught in one of my least favorite situations - the compiler believed what it saw - would have been better if the field-name did not exist (if only there was a "do what i meant" compile parameter). But think of all the "fun" you had icon_wink.gif

Good luck and be in touch.
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