‎2007 Dec 19 10:21 AM
HI,
I need a function module to convert a decimal variable to character .
For Eg.,
menge TYPE p DECIMALS 2, " Material Quantity
loan_val(11) TYPE p DECIMALS 2, " Loan value
I need these to convert to charecter.
‎2007 Dec 19 10:29 AM
‎2007 Dec 19 10:27 AM
The example includes an example of converting this floating-point decimal into a character field.
data:
floatout like qmih-auszt,
floatp type p decimals 0,
printhr(10).
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
INPUT = qmih-auszt
UNIT_IN = 'S'
UNIT_OUT = 'H'
IMPORTING
OUTPUT = floatout
EXCEPTIONS
CONVERSION_NOT_FOUND = 1
DIVISION_BY_ZERO = 2
INPUT_INVALID = 3
OUTPUT_INVALID = 4
OVERFLOW = 5
TYPE_INVALID = 6
UNITS_MISSING = 7
UNIT_IN_NOT_FOUND = 8
UNIT_OUT_NOT_FOUND = 9
OTHERS = 10.
move floatout to floatp.
move floatp to printhr.
condense printhr.
CONCATENATE
'Number of hours on part at failure: ' printhr INTO text6-tdline.
APPEND text6.
‎2007 Dec 19 10:28 AM
Use Function module:
CEVA_CONVERT_FLOAT_TO_CHAR.
Regards,
Gopi,
reward points if helpfull.
‎2007 Dec 19 10:29 AM
‎2007 Dec 19 10:30 AM
Hello,
I don't know a function module. However, the method I have used to achieve it is:
G_NUM_TEMP TYPE P DECIMALS 2
G_S_IMP_MOM TYPE /GEX/255 --> CHAR of 255
WRITE G_NUM_TEMP TO G_S_IMP_MOM NO-GROUPING LEFT-JUSTIFIED.
"NO-GROUPING in order to not to add thousand separator
"LEFT-JUSTIFIED for correctly doing if the sign is at the end of the number (maybe you shouldn't use it).
Then it is important to:
REPLACE ',' IN G_S_IMP_MOM WITH '.' . "SAP undertands decimals with '.' and not with ','
I hope it will help you.