09-15-2010 5:55 PM
Hi Friends
I have value in string like this
data val(30) type c value '10000'
and need this to be converted like this 10,000. How can i achieve this.
Thanks
09-15-2010 6:17 PM
Move it to a variable of type P or use the fm below
You can try this example
data val(30) type c value '10000'.
data:n type i.
CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
EXPORTING
string = val
DECIMAL_SEPARATOR = '.'
THOUSANDS_SEPARATOR = ','
* WAERS = ' '
IMPORTING
BETRG = n
* EXCEPTIONS
* CONVERT_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write n.
09-15-2010 6:54 PM
Sorry. I did not mentioned that I am in CRM System. I dont have this function Module.
Thanks
09-15-2010 7:03 PM
You can just move it to a variable of type p.
data:ch type char10 value '12345'.
data:pp type p decimals 3.
REPLACE ALL OCCURRENCES OF REGEX '[^0-9.]' IN ch WITH space.
condense ch.
pp = ch.
write pp.
09-15-2010 7:07 PM