06-23-2016 1:15 PM
REPORT ZDATATYPES.
data :
xyz type f VALUE '123',
pqr type p VALUE 12.
data : t type f.
t = xyz + pqr.
write : t.
"OUTPUT
1,3500000000000000E+02
Why the o/p comes with trailing zeroes? Is there a way to remove it without changing their datatypes?
06-30-2016 7:59 AM
You mix up two things:
The data object t has type f and for that reason the calculation type is f and the internal representation of the result is type f.
When using WRITE for any data type (here f), an implicit formatting of the output takes place that is described in the documentation. If you want to format your output in another way, use the respective formatting options.
In order to change the internal format, you assign to other data objects with other data types adhering to the conversion rules. You can also use the conversion operator CONV for that.
06-23-2016 2:50 PM
this is the text representation of your float variable.
For proper display you should pass the value on a char field by using a FM, there are quiete a few of those.
06-30-2016 7:34 AM
change result data type to packed ....
REPORT ZDATATYPES.
data :
xyz type f VALUE '123',
pqr type p VALUE 12.
data : t type p DECIMALS 2 . "DECIMALS 2.
t = xyz + pqr.
write : t.
06-30-2016 7:59 AM
You mix up two things:
The data object t has type f and for that reason the calculation type is f and the internal representation of the result is type f.
When using WRITE for any data type (here f), an implicit formatting of the output takes place that is described in the documentation. If you want to format your output in another way, use the respective formatting options.
In order to change the internal format, you assign to other data objects with other data types adhering to the conversion rules. You can also use the conversion operator CONV for that.