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

character to decimal conversion

Former Member
0 Kudos
5,422

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
Read only

Former Member
0 Kudos
2,303

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
Read only

Former Member
0 Kudos
2,303

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

Read only

former_member156446
Active Contributor
0 Kudos
2,303

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.

Read only

Former Member
0 Kudos
2,303

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.

Read only

former_member376453
Contributor
0 Kudos
2,303

try write statement.

suppose your char varriable is char and decimal variable is deci

try: write char to deci.

Kuntal

Read only

Former Member
0 Kudos
2,304

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