How to make spaces in zeroes position in cobol

Viewed 144

I have output for 9(13).9(02) ==000000000000000.00
I need to make it as 13 spaces.2 spaces.pls help to achieve.

Note: i tried "Blank when zeroes" I tried defining "3 alphanumeric values and move" still getting same.

Pls help.

Thanks in advance!!

1 Answers

output-field will contain either a formatted value fitting the pic or 13 spaces, a decimal-point, and 2 spaces when the value is zero.

Code:

   data division.
   working-storage section.
   01 field-with-value pic s9(9)v99 value zero.
   01 output-field value space.
   88 output-custom-field value "             .  ".
       02 formatted-field pic 9(13).9(02).
   procedure division.
       move +1 to field-with-value
       perform display-output-field
       move zero to field-with-value
       perform display-output-field
       stop run
       .

   display-output-field.
       if field-with-value = zero
           set output-custom-field to true
       else
           move field-with-value to formatted-field
       end-if
       display quote output-field quote
       .

Output:

"0000000000001.00"
"             .  "
Related