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

COMPARING COMP-3 Variables


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

New User


Joined: 14 Oct 2012
Posts: 5
Location: India

PostPosted: Tue Oct 16, 2012 10:55 pm
Reply with quote

Hello,
I have a variable V1 with PIC S9(9)C9(4) COMP-3.

Another variable is -- V2 PIC x(14)
V2-X redefines V2 as PIC 9(9).9(4).

Now, i have to compare V1 with V2 and if they are not equal, then i have to report the difference. Please help me on how to do this in COBOL.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Oct 16, 2012 11:04 pm
Reply with quote

Assuming your V1 is PIC S9(09)V9(4) COMP-3 instead of what you posted (which is not valid COBOL), why not compare V2-X to V1? What happened when you tried it? Since V1 has an implied decimal point, you cannot directly compare V1 to V2 since they would compare equal if and only if the fractional part of V1 was 0000 (the implied decimal point for a PIC X variable is always to the right of the last character).

Quote:
Please help me on how to do this in COBOL.
Why not use the obvious
Code:
IF  V1 NOT = V2-X
and see what happens?
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 JCL with variables JCL & VSAM 1
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
Search our Forums:

Back to Top