I want the data to be in decimal format in the spool. How can I print the data with decimal points. I have used
Pic 99v99
for my data-definition, but it is not showing a decimal-point in the result when I DISPLAY
it.
12.34
for the value of my data is displayed as 1234
The formula for converting DECIMAL DB2 data type to COBOL equivalent is−DECIMAL(p,q) = PIC S9(p-q)V(q). Where V indicates implied decimal. The DECIMAL(7,3) can take a sample value as 7861.237 and this can be converted to COBOL equivalent as PIC S9(7-3)V(3) = PIC S9(4)V(3).
Implied decimal simply means there is a decimal point implied at a specified location in a field, but not actually present in the file. For example, the number 123 with an implied decimal of two digits represents the actual value 1.23 Using implied decimal saves space in the file.
PIC 9 for numbers, optionally with S (sign) or V (implicit decimal point). For example, PIC S9(7)V99 means a signed number with 7 digits to the left of the implicit decimal point and 2 digits to the right.
The V
in 99V99
is just an "invisible" decimal-point that sets the correct alignment for any fixed-point-operations. It has the advantage that it doesn't take up any additional memory. If you want a comma that is displayed use a PIC
-clause like 99.99
which will
USAGE DISPLAY
, not on COMP
-fieldsNote: When using DECIMAL-POINT IS COMMA
you have to change the PIC
-clause accordingly to: PIC 99,99
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With