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

abap cal.

Former Member
0 Likes
804

Hi,

data : x_kwmeng(15).

data : y_weight(30) type c .

data : w_weight type p decimals 3.

x_kwmeng = '100.111'.

y_weight = '1,111.111'.

w_weight = ( ( x_kwmeng * y_weight * 1000 ) ).

write w_weight.

DUMP : Unable to interpret "1,111.111 " as a number.

Any Solution Pls.

Vind.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
787

Hi,

Please declare the variables as follows:

data : x_kwmeng type p.

data : y_weight type p.

data : w_weight type p decimals 3.

x_kwmeng = '100.111'.

y_weight = '1111.111'. --> removed comma in the amount field

w_weight = ( ( x_kwmeng * y_weight * 1000 ) ).

write w_weight.

You can still declare the variables as char type but recommended to declare them as type P as they are amount fields. and the reason for getting the dump is giving comma in the Y_WEIGHT field that i have removed.

Regards,

yellappa.

Hi,

data : x_kwmeng(15).

data : y_weight(30) type c .

data : w_weight type p decimals 3.

x_kwmeng = '100.111'.

y_weight = '1,111.111'.

w_weight = ( ( x_kwmeng * y_weight * 1000 ) ).

write w_weight.

DUMP : Unable to interpret "1,111.111 " as a number.

Any Solution Pls.

Vind.

5 REPLIES 5
Read only

Former Member
0 Likes
787

Remove ',' coma in the char field

y_weight = '1111.111'.

Read only

Former Member
0 Likes
788

Hi,

Please declare the variables as follows:

data : x_kwmeng type p.

data : y_weight type p.

data : w_weight type p decimals 3.

x_kwmeng = '100.111'.

y_weight = '1111.111'. --> removed comma in the amount field

w_weight = ( ( x_kwmeng * y_weight * 1000 ) ).

write w_weight.

You can still declare the variables as char type but recommended to declare them as type P as they are amount fields. and the reason for getting the dump is giving comma in the Y_WEIGHT field that i have removed.

Regards,

yellappa.

Read only

0 Likes
787

Hi

y_weight = '1,111.111'. is the run time value thats been assigned to the variable . so cant exclude the comma .

Thanks ,

Vind.

Read only

0 Likes
787

If that is the case then remove the comma in the amount field as below and use the code as usual.

REPLACE ALL OCCURRENCES OF ',' IN y_weight WITH SPACE.

CONDENSE Y_WEIGHT NO-GAPS.

if your system doesn't support REPLACE ALL OCCURRENCES then use following code.

do.

replace ',' with space into y_weight.

if sy-subrc <> 0.

exit.

endif.

enddo.

CONDENSE Y_WEIGHT NO-GAPS.

Once after using above statement then use y_weight in your calculations.

Note: Since we are using condense statement please declare the y_weight as char type or else it will go to dump.

Regards,

Yellappa.

Edited by: yellappa m on Feb 21, 2008 6:26 PM

Read only

0 Likes
787

Hi yellappa m

I just resolved my issue by reading your answer. Brilliant idea.

Just wanted to say Thank you.

-ASB