View previous topic :: View next topic
|
Author |
Message |
harry07 Warnings : 1 New User
Joined: 15 Nov 2006 Posts: 7
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
harry07 Warnings : 1 New User
Joined: 15 Nov 2006 Posts: 7
|
|
|
|
hi
I would like it for display purpose only & nothing is required for mathematical calculations. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
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 |
|
|
|