Search code examples
editnumericcobol

How to move sign separate trailing to normal decimal field in COBOL


I have a field like 03 ws-var1 Pic s9(11)v9(2) sign trailing separate.

In the op file the value gets displayed as 00000002999200+

But I want it to be displayed as 29992.00. What definition has to be made in COBOL to so tht I get this desired result.


Solution

  • PICTURE Result Length Notes
    +9(11).9(2) +00000029992.00 15 The sign + or - will be shown
    -9(11).9(2) 00000029992.00 15 The - will show only if the value is negative
    +(11)9.9(2) +29992.00 15 The sign + or - will be shown
    -(11)9.9(2) 29992.00 15 The - will show only if the value is negative
    Z(10)9.9(2) 29992.00 14 The sign is removed.

    In each case spaces will be present before each result if the number of characters shown is less the the length of the field.