IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

comparing alphanumeric with comp-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sumivel

New User


Joined: 13 Sep 2005
Posts: 18

PostPosted: Mon Jun 26, 2006 6:06 pm
Reply with quote

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
View user's profile Send private message
IQofaGerbil

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Mon Jun 26, 2006 7:31 pm
Reply with quote

what value do you have in b ?
Back to top
View user's profile Send private message
SIVAMAIN

New User


Joined: 24 Jun 2006
Posts: 12

PostPosted: Mon Jun 26, 2006 8:20 pm
Reply with quote

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
View user's profile Send private message
sumivel

New User


Joined: 13 Sep 2005
Posts: 18

PostPosted: Tue Jun 27, 2006 2:20 pm
Reply with quote

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
View user's profile Send private message
luban

New User


Joined: 19 Nov 2005
Posts: 26
Location: Shanghai, China

PostPosted: Sat Jul 01, 2006 9:57 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jul 27, 2006 4:15 am
Reply with quote

Hi Sumivel,

Go to the manuals at this site and do some reading about NUMVAL and NUMVAL-C.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top