View previous topic :: View next topic
|
Author |
Message |
sumivel
New User
Joined: 13 Sep 2005 Posts: 18
|
|
|
|
The given Spec is as follows
01 a pic x(7) value '123.456'
.
.
.
01 b pic s9(3)v9(3) comp.
if a = b
display 'equal'
else
display'not equal'
**************************************
i tried comparing by redefining
'a' with pic clause 9(3)v9(3)...
it didnot work...can anyone help
me for the above problem. |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
what value do you have in b ? |
|
Back to top |
|
|
SIVAMAIN
New User
Joined: 24 Jun 2006 Posts: 12
|
|
|
|
hi sumivel , this is siva
by coding we can do
WORKING-STORAGE SECTION.
01 A PIC X(5) VALUE IS '12345'.
01 B PIC 9(5) VALUE 12345.
PROCEDURE DIVISION.
IF A = B THEN
DISPLAY 'EQUAL'
ELSE
DISPLAY 'NOT EQUAL'
END-IF.
DISPLAY A.
DISPLAY B.
but when i tried the following code it showing error
WORKING-STORAGE SECTION.
01 A PIC X(6) VALUE IS '123.45'.
01 B PIC 9(3)V99.
PROCEDURE DIVISION.
MOVE 123.45 TO B.
IF A = B THEN
DISPLAY 'EQUAL'
ELSE
DISPLAY 'NOT EQUAL'
END-IF.
DISPLAY A.
DISPLAY B.
error shown by complier
IGYPA3022-S "A (ALPHANUMERIC)" was compared with "B (NUMERIC NON-INTEGER)". The comparison was discarded. |
|
Back to top |
|
|
sumivel
New User
Joined: 13 Sep 2005 Posts: 18
|
|
|
|
i am working on web based COBOL Program....my input from web will be colledcted in variable say DISCOUNT with pic clause X(7)...in the program the DISCOUNT from the web shud be compared with the host variable WS-DISCOUNT with pic clause s9(3)v9(3) comp-3.
SAY....
01 DISCOUNT PIC x(7). let's value be 123.456
my host variable
WS-DISCOUNT PIC S9(3)V9(3) COMP-3 |
|
Back to top |
|
|
luban
New User
Joined: 19 Nov 2005 Posts: 26 Location: Shanghai, China
|
|
|
|
Hi Sumivel,
I think you can't compar alphanumeric with comp-3 in COBOL.
Maybe a numeric variable is needed.
Best regards,
Ban |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sumivel,
Go to the manuals at this site and do some reading about NUMVAL and NUMVAL-C. |
|
Back to top |
|
|
|