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

Want to see if the difference between the two fields is >


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

New User


Joined: 24 Jul 2006
Posts: 18

PostPosted: Mon Aug 07, 2006 6:11 pm
Reply with quote

Hi,

Ok, trying to clear the Cobol cobwebs. I have these 3 fields:

05 WW-SEG-01 PIC X(10).
05 WW-SEG-01-RE REDEFINES WW-SEG-01.
10 WW-SEG-01-N PIC 9(04).
10 WW-SEG-01-N2 PIC 9(06).

05 WW-PREV-SEG-01 PIC 9(04) VALUE 0.

05 WW-DIFF PIC 9(04) VALUE 0.

and this calc:

COMPUTE WW-DIFF = (WW-SEG-01-N - WW-PREV-SEG-01 )

Basically, I want to see if the difference between the two fields is > 1
and then...do something

IF WW-DIFF > 1
DISPLAY '********************************'
DISPLAY 'WW-SEG-01-N : ' WW-SEG-01-N
DISPLAY 'WW-PREV-SEG-01: ' WW-PREV-SEG-01
DISPLAY 'WW-DIFF : ' WW-DIFF
END-IF

This is what displays when I run my program:
WW-SEG-01-N : 10
WW-PREV-SEG-01: 9 0
WW-DIFF : 8000

Any idea why ?
Thanks,
J.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Aug 07, 2006 11:11 pm
Reply with quote

J,

Without knowing exactly what your input values are it's difficult to tell you exactly why you're getting the results you are. The results appear to contradict each other in formatting.

However, I think your question is why you 10 ? 90 = 80? The problem is that the result field is defined as a non signed field. The result is the Absolute (positive) vale for the number. Define the result field as S9(4). Your results will be different.

Dave
Back to top
View user's profile Send private message
jtwohig

New User


Joined: 24 Jul 2006
Posts: 18

PostPosted: Mon Aug 07, 2006 11:27 pm
Reply with quote

Thanks Dave. Had a temporary memoery lapse but I have figured this problem out...
J
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 Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts What is the difference between Taskty... Compuware & Other Tools 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top