View previous topic :: View next topic
|
Author |
Message |
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi,
Please throw some light into this.
I have a two fields with following definition
PAYEE-NO PIC 9(10). This is an array variable.
PAYEE-ID-NO PIC 9(10) COMP-3.
Following are the values contained in two fields.
PAYEE-ID-NO (1) = 0000000000
PAYEE-NO = ??????????? INVALID DECIMAL
In normal case the following statement should not be satisfied correct?
WHEN PAYEE-ID-NO = PAYEE-NO (1)
But in my execution this statement is getting satisfied.
Can an invalid decimal value be equal to COMP-3 zeroes.
Please help.
Thanks and Regards,
Abin. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
one place you are talking about
Code: |
PAYEE-NO PIC 9(10). This is an array variable.
PAYEE-ID-NO PIC 9(10) COMP-3.
|
another where you are indexing a non-array element
Code: |
PAYEE-ID-NO (1) = 0000000000
PAYEE-NO = ??????????? INVALID DECIMAL
|
and here you are complaining about a WHEN statement with yet 2 new elements.
Code: |
WHEN L3001-CHN-PHAR-PAYEE-ID-NO = CHN-PAYEE-NUMBER (1)
|
much too confusing. now, if you would provide data descriptions and contents of the the variables in the WHEN statement, maybe we could help. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
sorry for the confusion.
The when is in a search table statement.
SEARCH PROCESS-INFO VARYING P-ID
AT END
MOVE 1 TO WS-TBL-FOUND-IND
WHEN PAYEE-ID-NO
= PAYEE-NO (P-ID)
The table definition is as follows.
01 PROCESS-TABLE.
05 PROCESS-INFO
OCCURS 1 TO 500 TIMES
OCCURS 1 TO 1000 TIMES
DEPENDING ON WS-NUMBER-OF-TIMES
INDEXED BY P-ID.
10 PAYEE-NO PIC 9(10).
10 PAYEE-IND PIC X(01).
10 PAYEE-SUB-ID PIC X(11).
10 PAYEE-ID-QUAL PIC X(02).
10 PAYEE-ID PIC X(10).
10 PAYEE-IND-A PIC X(01).
10 PAYEE-PLB-IND PIC X(01).
Definition of PAYEE-ID-NO is as follows.
PAYEE-ID-NO PIC 9(10) COMP-3.
Values of fields at time of execution of code in question:
P-ID=1
PAYEE-NO (P-ID) = ??????????? (Invalid decimal)
PAYEE-ID-NO = 0000000000
Hope this clears the matter.
Regards,
Abin. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
OK, I'll bite, who or what decieded that PAYEE-NO (1) equaled a string of question marks? Or is that meaning unknown value? Who said thea it was "invalid decimal"?
One more thing, what platform is this running on? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
oh boy, oh boy, oh boy.
Code: |
SEARCH PROCESS-INFO VARYING P-ID
AT END
MOVE 1 TO WS-TBL-FOUND-IND
WHEN PAYEE-ID-NO = PAYEE-NO (P-ID)
|
When you have a no find, you are setting WS-TBL-FOUND-IND to 1. What does that mean? To what value is it initially SET? meaning what?
what code follows the WHEN clause to the END-SEARCH?
what code follows the END-SEARCH?
are you initializing P-ID to 1 before you start your search?
is WS-NUMBER-OF-TIMES populated correctly?
is have two occurs clauses 'NEW COBOL'?
Code: |
01 PROCESS-TABLE.
05 PROCESS-INFO
OCCURS 1 TO 500 TIMES
OCCURS 1 TO 1000 TIMES
DEPENDING ON WS-NUMBER-OF-TIMES
INDEXED BY P-ID.
|
I image your problem is the AT END clause. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi William,
I used Xpeditor for debugging the code.
What I got is this.
Code: |
10 PAYEE-ID-NO > 0000000000 PACKED
I=1 OCCURS
10 PAYEE-NO > ??????????? INVALID DECIMAL
P-IDX > 1 INDEX
** END ** |
When I ran the code using JCL I got the same result. I mean the WHEN satisfies. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
You haven't really answered questions asked by dbz, most important about OCCURS clause.
About XPEDITOR,
Try redefining PAYEE-NO with an alphanumeric variable with same number of bytes as PAYEE-NO, may be that will show you the contents. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi dbzTHEdinosauer,
I dont think it's the problem with AT END clause, because in my case it does not goes to the AT END clause.
Code that follows from WHEN clause to the END-SEARCH is some MOVE statements, which has no effect on WHEN statement.
Sorry for this, one OCCURS is commented out.
Code: |
01 PROCESS-TABLE.
05 PROCESS-INFO
OCCURS 1 TO 1000 TIMES
DEPENDING ON WS-NUMBER-OF-TIMES
INDEXED BY P-ID. |
.
P-ID is initilized to 1 before statrting the search.
WS-NUMBER-OF-TIMES will be populated with the exact number of entries in the table.
Regards,
Abin. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi agkshirsagar,
The first entry in the table has some undefined value LOW-VALUE or HIGH-VALUE. Whatever, it is a value that should not be there in a decimal field.
My doubt how is an invalid decimal equals to COMP-3 zeroes. Please clarrify whether this is possible or not.
Regards,
Abin. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
My doubt how is an invalid decimal equals to COMP-3 zeroes. Please clarrify whether this is possible or not.
|
No, it is not possible. you are overlooking something. When you are looking at the xpediter data display, is that during the WHEN clause. Do you have a break on a WHEN clause statement (to be executed) and then look at the data.
You might also look at PROCESS-INFO - the group item in hex.
xpediter can be tricky when it comes to indexes. You have to know when to look. Are you going to a display data screen, or are you using the watch data option - displays above the code display. you can have several data areas in the watch area as you step thru your code.
try adding this code to the statements that are executed when the WHEN clause is satisfied
Code: |
DISPLAY PAYEE-ID-NO
DISPLAY PAYEE-NO(P-ID)
|
neither COBOL or Xpediter performs the compare incorrectly. You are not looking at the data at the correct time.
Again, take a look at the group item PROCESS-INFO in hex. ID number is first so you don't even have to find it with page-right. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
hi dbzTHEdinosauer,
Please see what I get in the PROCESS-INFO.
I am using watch data option to see the field values.
Code: |
----+----1----+----2----+----3
SAME-> K 05 PROCESS-INFO > .........0....................
003318 10 PAYEE-ID-NO > 0000000000 PACKED
I=1 OCCURS
000487 10 PAYEE-NO > ??????????? INVALID DECIMAL
COBOL P-ID > 1 INDEX
** END **
------ ------------------------------------- Before L00676E:4392/AMODE 31 <>
004383 2300-SEARCH-CHAIN-TABLE.
004384 B IF PAYEE-ID-NO = PAYEE-ID
004385 CONTINUE
004386 ELSE
004387 MOVE 0 TO WS-TBL-FOUND-IND
004388 SET P-ID TO 1
004389 SEARCH PROCESSOR-INFO VARYING P-ID 0006
004390 AT END
004391 MOVE 1 TO WS-TBL-FOUND-IND
=====> B WHEN PAYEE-ID-NO
= PAYEE-NO (P-ID) |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
10 PAYEE-NO PIC 9(10). is display.
Code: |
----+----1
SAME-> K 05 PROCESS-INFO > .........0
|
the 10th byte of PAYEE-NO is a 0 (zero). You are working with numbers and using an unsigned display field. COBOL assumes the programmer is an an idiot (don't take it personally ). try a compound WHEN -
WHEN PAYEE-NO(P-ID) NUMERIC AND ..... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How is the array loaded?
Before using the values in the array, you might want to execute a bit of code to ensure that all of the values in the array are valid. If any are not, display them in hex and terminate the run.
Before running again, make sure the array will be loaded with valid values. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi Scherrer,
Actually the array is loaded incorrectly. This is a production code and running ffor years now. still nobody noticed this thing.
The array is loaded from a flat file. The first entry in the array is loaded before the file is readed. So, the first entry will always be an uninitialized entry.
My concern is how can be an invalid decimal be equal to hex zeroes.
Please stop me if I am speaking nonsense.
Regards,
Abin. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello, Abin,
You're not speaking nonsense - we are trying to make sure we all have the same understanding.
Well, "hex zeros" is an invalid decimal number. . . . Is it possible that the data actually contains hex zeros?
If you can show the hex values in the array and the hex values that are being compared to the entries in the array, it will surely help.
Something else that may help is to isloate the array, loading the array and comparing agains the array in a separate bit of code that exists only for testing this situation. It would probably be a very small program
Even though this has been in operation for a long time, it would be a good idea to correct it. As it is, it may or may not work correctly in all cases. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi Scherrer,
I did a display on the fields and following are the HEX of the spool. HEX zero is F0 right? then what is this 00? IS F0 equals to 00.
Code: |
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
------------------------------------------------------------------------------
000001 PAYEE-ID-NO 0000000000
4DCECC6CC6DD4FFFFFFFFFF4444444444444444444444444444444444444444444444444
071855094056000000000000000000000000000000000000000000000000000000000000
------------------------------------------------------------------------------
000002 PAYEE-NO (P-ID) 0
4DCECC6DD44D6CC54000000000F444444444444444444444444444444444444444444444
0718550560D7094D00000000000000000000000000000000000000000000000000000000
------------------------------------------------------------------------------
****** **************************** Bottom of Data **************************** |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
did you try adding to the WHEN statement the additional check for IS NUMERIC? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
x'F0' is a display zero.
x'00' is hex zero.
They will not compare equal. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi,
I tried with additional check of NUMERIC. Now WHEN statement is not satisfying. That means what is there in the array is not numeric. But this we found earlier and my concern is how can an invalid numeric be equals to COMP-3 zeroes.
Thanks,
Abin. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
In the data you posted, there is no comp-3 zeros.
You have one field of display zeros and one garbage field of several x'00's and one display zero at the end.
You may have defined something as comp-3 but you do not have a comp-3 value. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
how can an invalid numeric be equals to COMP-3 zeroes. |
I told you before, if you use PIC 9 DISPLAY, COBOL treats you like an idiot and will allow just about anything to happen. That is why you need to qualify any computation or compare with a numeric display field with a preceding IS NUMERIC. Now, had the array been composed of decimal definitions (COMP-3) then you would not have any problems.
until you combine the compare with the IS NUMERIC, you do not have invalid numerics.
RTFM!!!!! |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi Scherrer,
PAYEE-ID-NO is a comp-3 field, But in my shop when I display comp-3 field in spool it will be displayed in a readable format.
I am using IOF not SDSF.
Now what I understand is because COBOL treated me as an idiot it went it's on way and gave an undesirable and unpredictable result. Great
Thanks,
Abin. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
Now what I understand is because COBOL treated me as an idiot it went it's on way and gave an undesirable and unpredictable result. Great
|
abin,
The behavior of the machine is predictable. You just have to read the manuals (or in this case, learn from experience). PIC 9 DISPLAY is well documented. Unless you qualify with IS NUMERIC, PIC 9 DISPLAY fields will do what ever you tell them to, regardless of their content, because they are not bound by the rules governing truly numeric definitions.
you are feeling foolish because you made an assumption, don't continue making assumptions. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Abin,
If you have the time and the inclination, change the value in the array to ALL x'00's (getting rid of the x'F0' at the end). Your results will not be the same. Again, if you want to see more of exactly what happened, take a look at the assembler code that was generated to do the compare.
Quote: |
PAYEE-ID-NO is a comp-3 field |
Only by definition - not by content. A comp-3 field must contain
where the d's are digits that must be zero thru nine and the s must be a valid sign.
As DBZ points out, there is a wealth of material in the manuals (which are avaliable via the "Manuals" link at the top of the web page). |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi,
Sorry for being late to reply. I am stuck in another important work. I'll do as you suggetsted and let you know of the results.
Thanks for all the support.
Abin. |
|
Back to top |
|
|
|