Application Development 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: 

Thousand Seperator for Character Value

Former Member
0 Kudos

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

4 REPLIES 4

kesavadas_thekkillath
Active Contributor
0 Kudos

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.

0 Kudos

Sorry. I did not mentioned that I am in CRM System. I dont have this function Module.

Thanks

0 Kudos

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.

Former Member
0 Kudos

Thanks Kesav