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

Suggest Field definition for Negative values


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

New User


Joined: 15 Nov 2006
Posts: 7

PostPosted: Fri Nov 17, 2006 10:14 pm
Reply with quote

Hi
Please suggest the field definition for my requirement below.

If the field is negative it should be occupy first position in the field
& if not positive then the first position should be occupied by zero & not spaces.

Suppose if the field is 1 & pic 9(9).9(2)

if negative should be displayed as -00000001.00
if positive should be displayed as 000000001.00

Please let me know your inputs on the same.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Nov 19, 2006 2:12 am
Reply with quote

Hi Harry,

You didn't say what you plan to do after you get what you want. What you defined in your post is a numeric edited field and you can only use it for display purposes, i.e. you can't do math on it.

So, how do you plan to use it. An answer (if any) depends on the ans to this ques.
Back to top
View user's profile Send private message
harry07
Warnings : 1

New User


Joined: 15 Nov 2006
Posts: 7

PostPosted: Sun Nov 19, 2006 2:27 am
Reply with quote

hi
I would like it for display purpose only & nothing is required for mathematical calculations.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Nov 20, 2006 2:24 am
Reply with quote

Hi Harry,

Your PIC s/b be something like pic -9(9).9(2). That will display the minus sign when the value is neg.

If it's pos you can do something like this:

IF VAR(1:1) = SPACE
MOVE ZERO TO VAR(1:1)
END-IF

Or you can move in a '+' (my choice), but you know your requirements better than me (er.. I).

Can't think of anything more elegant.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Mon Nov 20, 2006 2:15 pm
Reply with quote

Hi !

Why not using a mask like:

01 ZNUM-1206 PIC +++++++++++9,999999.
01 ZNUM-1602 PIC +++++++++++++++9,99.
01 ZNUM-1800 PIC ZZZZZZZZZZZZZZZZZ9.
01 ZNUM-0400 PIC ZZZ9.
01 ZNUM-08BB PIC 999B999B99.

Regards, UmeySan
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top