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: 

character to decimal conversion

Former Member
0 Kudos

HI folks,

I have an amount value as '449,00' in variable of char16 type. I need to convert that into a variable of type p length 13 decimal 2.........

Please help me out..........

thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

data: lv_dec type p decimals 2.

first split the number into two

split <number> at ',' into lv_char1 lv_char2.

lv_dec = lv_char1.

write:/ lv_dec.

answer:

lv_dec = 449.00

5 REPLIES 5

Former Member
0 Kudos

Try declaring a decimal type variable and moving the character to that variable....

former_member156446
Active Contributor
0 Kudos

Check this code which I wrote for you:

DATA: char TYPE char16 VALUE '449,00',
      p(13) TYPE p DECIMALS 2.

REPLACE ALL OCCURRENCES OF ',' IN char WITH space.

p = char.

p = p / 100.

WRITE: p.

Former Member
0 Kudos

Hi,

Use FM CLSE_SELECT_USR01 and get user default decimal sign and separator.

Then replace user decimal sign with dot(.) and separator with space in character variable and condense and then move to your required variable.

Regards,

Raju.

former_member376453
Contributor
0 Kudos

try write statement.

suppose your char varriable is char and decimal variable is deci

try: write char to deci.

Kuntal

Former Member
0 Kudos

data: lv_dec type p decimals 2.

first split the number into two

split <number> at ',' into lv_char1 lv_char2.

lv_dec = lv_char1.

write:/ lv_dec.

answer:

lv_dec = 449.00