View previous topic :: View next topic
|
Author |
Message |
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Hi
Please consider the data below :
Code: |
01 CC-TEMP1.
05 CC-X1 PIC S9(7) COMP-3.
05 CC-X2 PIC X(5).
01 CC-TEMP2.
05 CC-Y1 PIC 9(7) .
05 CC-Y2 PIC X(5). |
Please note that CC-X1 & CC-Y1 are defined diffrently ( one is comp 3).
If I execute following statement
Code: |
IF CC-TEMP1 NUMERIC |
The result is , it never identifies it as numeric even if the actual data is numeric.
Where as
Code: |
IF CC-TEMP2 NUMERIC |
Correctly identifies it as NUMERIC.
Please note that data is same ( which is numeric ) in both the variables.
Can some one please explain this to me ? |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Have you checked the Language Reference manual? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
ap_mainframes wrote: |
Can some one please explain this to me ? |
Yes, but only if you display both fields to the terminal with HEX ON and post them here..... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Can some one please explain this to me ? |
Why might you believe that the same value would be valid in both of those definitions?
Quote: |
it never identifies it as numeric even if the actual data is numeric. |
Your misconception is this - the actual data is not numeric.
As Terry mentioned, some time in the COBOL Language Reference should help you understand.
At the top of the page is a link to "IBM Manuals". Among them are the Language Reference for multiple current cobol compilers.
If you find something in the manual that is not clear, post what you found and your question. Someone will be able to clarify. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
COBOL is doing exactly what the manuals says it is supposed to do -- which is obviously not what you expected. CC-TEMP2 is a group of like-defined fields, each of which is numeric. So it is numeric. CC-TEMP1 is a group of fields (one of which is signed), which changes some of the rules of IF NUMERIC. The manual explains all (or at least almost everything) and should be your first reference book -- always. |
|
Back to top |
|
|
|