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: 

amount conversion

Former Member
0 Kudos
203

hi to all,

help me inthis issue

amount2 = 860.851,00 i want to divide it by 100 for jpy currency

but when i keep above amount1 = amount2 / 100.

it is going to dump.

thanks in advance

kiran reddy

6 REPLIES 6

andreas_mann3
Active Contributor
0 Kudos
129

hi

convert your char- value to a p-value

use fm prpare_string:

DATA digit(11) VALUE ' 0123456789'.

data: var(16) value '860.851,00'.

DATA var_new(16).

DATA s(2) VALUE ' 0'.

var_new = var.

CALL FUNCTION 'PREPARE_STRING'

EXPORTING

i_valid_chars = digit

i_xvalid_check = 'X'

i_xchar_repl = 'X'

i_xtoupper = 'X'

CHANGING

c_string = var_new.

CONDENSE var_new NO-GAPS.

amount2 = var_new / <b>10000</b>.

Message was edited by:

Andreas Mann

0 Kudos
129

hi both the amount are of char type

thanks in advance

kiran reddy

0 Kudos
129

amount2 <b>must</b> be a <b>numeric</b> if you want to use an arithmetic operation

regards Andreas

Former Member
0 Kudos
129

Hi Kiran,

System will not consider '860.851,00' as number because of comma. First you need to remove the commas & dots form it. then do the airthmetic operation.

e.g.:

amount3 = '860851.00'.

amount1 = amount3 / 100.

Ashven

Former Member
0 Kudos
129

Kiran,

Can you please let me know, why you are taking amount2 as character.

Thanks,

Sri.

Former Member
0 Kudos
129

the reason u r getting a dump is

'amount 2 is character 'valued as ' 860. 851,00'

. and , are not iterpreted as number

if u see the dump analysis in ST 22 it will be as

<b>not able to recognise '.' as number .</b>

i can divide that value with decimals only if its numeric format .

declare amount2 as currency format .

regards,

vijay.