Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SEARCH ALL - WHEN statement ignored

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: SEARCH ALL - WHEN statement ignored
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

Site Director


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

PostPosted: Tue Mar 13, 2007 2:22 am    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Mar 13, 2007 2:38 am    Post subject:
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

Site Director


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

PostPosted: Tue Mar 13, 2007 3:46 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Mar 13, 2007 8:26 am    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Mar 13, 2007 5:34 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Mar 13, 2007 7:57 pm    Post subject:
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    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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts ON 2 AND EVERY 1 - Statement ??? UmeySan COBOL Programming 2 Tue Jul 25, 2017 1:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us