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

Handling negative signs in EZtrieve


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ajeevlal

New User


Joined: 19 Feb 2005
Posts: 9
Location: Chennai

PostPosted: Fri Aug 17, 2007 4:51 pm
Reply with quote

i have this below simple eztrieve program.

WS-VAR1 W 7 N VALUE 0
WS-VAR2 W 7 N VALUE 0
WS-DIFF W 7 N VALUE 0

JOB INPUT NULL

WS-VAR1 = 9
WS-VAR2 = 2
WS-DIFF = WS-VAR2 - WS-VAR1
DISPLAY 'WS-VAR2 ' WS-DIFF
IF WS-DIFF LE 0
DISPLAY ' LESS THAN '
ELSE
DISPLAY ' GREATER '
END-IF
STOP

The output of the above program is 7 (positive), actually 2-9 is -7. is there any way to identify negative values during computation in eztrieve.
Back to top
View user's profile Send private message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Fri Aug 17, 2007 4:59 pm
Reply with quote

Hi Ajeevlal,

User Masking to get Negative sign in output.
Remember for negative masking sign needs to be put after digits.
Back to top
View user's profile Send private message
Ajeevlal

New User


Joined: 19 Feb 2005
Posts: 9
Location: Chennai

PostPosted: Fri Aug 17, 2007 5:55 pm
Reply with quote

thanks. i have tried using mask

WS-VAR1 W 7 N VALUE 0
WS-VAR2 W 7 N VALUE 0
WS-DIFF W 7 N VALUE 0 MASK 'ZZZZZ99-'

JOB INPUT NULL

WS-VAR1 = 9
WS-VAR2 = 2
WS-DIFF = WS-VAR2 - WS-VAR1
DISPLAY 'WS-VAR2 ' WS-DIFF
IF WS-DIFF LE 0
DISPLAY ' GREATER '
ELSE
DISPLAY ' LESS THAN '
END-IF
STOP

but still the same result.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Aug 17, 2007 6:27 pm
Reply with quote

Quote:
If you specify a numeric field with no decimal positions, CA-Easytrieve/Plus considers that field unsigned
Try
WS-DIFF W 7 N 0 VALUE 0
Back to top
View user's profile Send private message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Fri Aug 17, 2007 6:43 pm
Reply with quote

Hi Ajeevlal,

I think it can be done only with Signed decimal field.

Try with WS-DIFF W 8 P 2 MASK 'Z,ZZZ,ZZZ,ZZZ,ZZ9.99-' VALUE 0.
Back to top
View user's profile Send private message
Ajeevlal

New User


Joined: 19 Feb 2005
Posts: 9
Location: Chennai

PostPosted: Sat Aug 18, 2007 1:08 pm
Reply with quote

Thank you all guys.

both

WS-DIFF W 7 N 0 VALUE 0
and
WS-DIFF W 8 P 2 MASK 'Z,ZZZ,ZZZ,ZZZ,ZZ9.99-' VALUE 0.

worked well. icon_biggrin.gif
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 -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts File Handling COBOL Programming 9
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts SORT for dynamic trailer record + CSV... DFSORT/ICETOOL 14
No new posts Negative dependency between jobs in m... COBOL Programming 12
Search our Forums:

Back to Top