Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

COMPARING COMP-3 Variables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: COMPARING COMP-3 Variables
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: 7995
Location: Bellevue, IA

PostPosted: Tue Oct 16, 2012 11:04 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us