Skip to Content
avatar image
Former Member

Function module to convert decimal to character

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Dec 19, 2007 at 10:29 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 10:28 AM

    Use Function module:

    CEVA_CONVERT_FLOAT_TO_CHAR.

    Regards,

    Gopi,

    reward points if helpfull.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 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.

    Add comment
    10|10000 characters needed characters exceeded