Page 1 of 1

Need minus sign before the number

PostPosted: Wed Nov 22, 2017 4:36 pm
by ndashore20
Hi

I need to insert minus sign before the negative decimal value.

I tried the below code but it does not looks good while displaying.

WS-NUM          PIC S9(7)V99.
WS-DISP          PIC -ZZZ,ZZ9.99.
MOVE -713.55 to WS-NUM.
MOVE WS-NUM to WS-DISP.
DISPLAY'WS-NUM:'WS-NUM.
DISPLAY'WS-DISP:'WS-DISP.
 


OUTPUT:

WS-NUM:000071355N
WS-DISP:-   713.55( // spaces present between - & 7)
 

I think the spaces is present because of using Z in WS-DISP field definition.

I want the WS-DISP as
WS-DISP:       -713.55
(// No space should be present between - & 7)

It means I want to insert spaces before the minus sign if the number of digits less than the required.

I hope I am clear with the question? :P

Re: Need minus sign before the number

PostPosted: Wed Nov 22, 2017 5:54 pm
by Robert Sample
Another case of someone NOT reading the manuals and desperately needing to. Try
WS-DISP          PIC ----,--9.99.

Re: Need minus sign before the number

PostPosted: Wed Nov 22, 2017 6:47 pm
by ndashore20
yeah sorry for not reading manual properly ...

yeah its working thanks for your response

Re: Need minus sign before the number

PostPosted: Fri Nov 24, 2017 10:08 pm
by Terry Heinze
ndashore20,
You might want to add another minus sign since a negative 7-digit number will truncate.
-1234567.89 will display as -234,567.89
(untested)