Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function module to convert decimal to character

Former Member
0 Likes
4,615

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.

1 ACCEPTED SOLUTION
Read only

Vijay
Active Contributor
0 Likes
1,504

hi

u need not find ant fm.

just declare 2 variables of type character and assign ur decimal variables to them.

regards

vijay

reward points if helpfull

4 REPLIES 4
Read only

Former Member
0 Likes
1,504

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.

Read only

Former Member
0 Likes
1,504

Use Function module:

CEVA_CONVERT_FLOAT_TO_CHAR.

Regards,

Gopi,

reward points if helpfull.

Read only

Vijay
Active Contributor
0 Likes
1,505

hi

u need not find ant fm.

just declare 2 variables of type character and assign ur decimal variables to them.

regards

vijay

reward points if helpfull

Read only

Former Member
0 Likes
1,504

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.