Need minus sign before the number



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Need minus sign before the number

Postby ndashore20 » Wed Nov 22, 2017 4:36 pm

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
ndashore20
 
Posts: 11
Joined: Sun Sep 25, 2016 10:28 pm
Has thanked: 10 times
Been thanked: 0 time

Re: Need minus sign before the number

 

Re: Need minus sign before the number

Postby Robert Sample » Wed Nov 22, 2017 5:54 pm

Another case of someone NOT reading the manuals and desperately needing to. Try
WS-DISP          PIC ----,--9.99.
Robert Sample
Global moderator
 
Posts: 3419
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 235 times

Re: Need minus sign before the number

Postby ndashore20 » Wed Nov 22, 2017 6:47 pm

yeah sorry for not reading manual properly ...

yeah its working thanks for your response
ndashore20
 
Posts: 11
Joined: Sun Sep 25, 2016 10:28 pm
Has thanked: 10 times
Been thanked: 0 time

Re: Need minus sign before the number

Postby Terry Heinze » Fri Nov 24, 2017 10:08 pm

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)
.... Terry
Terry Heinze
 
Posts: 196
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 10 times
Been thanked: 11 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post