View previous topic :: View next topic
|
Author |
Message |
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi J,
You're welcome
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 |
|
Back to top |
|
|
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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...... |
|
Back to top |
|
|
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
Thanks again William. Unfortunately, I'm sure this won't be the last time I'm chasing my tail... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi J,
I hate when i do that. . . .
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
Good luck and be in touch. |
|
Back to top |
|
|
|