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

Numeric conversion

Former Member
0 Likes
1,934

Hi,

One of the variables has values stored as 2,000.000

I need to modify this to 2000

ANy ideas?

regards

Message was edited by: Nishant Gupta

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,896

You must first get rid of the comma, then move to an integer field.



report zrich_0001.


data: c(15) type c value '2,000.00'.
data: i type i.

translate c using ', '.
condense c no-gaps.

i = c.
write:/ i.

Regards,

Rich Heilman

12 REPLIES 12
Read only

Former Member
0 Likes
1,896

hi,

take data type interger.

dirrectly assigne to it.

Read only

Former Member
0 Likes
1,896

move that value to an integer type variable.

REgards,

Ravi

Read only

Former Member
0 Likes
1,896

hii

change the decimal settings in your system

Read only

Former Member
0 Likes
1,896

Hi,

var2 type I.

var1 = 2,000.000

var2 = var1.

rgds,

latheesh

Read only

0 Likes
1,896

i tried moving it to integer type variable..

i am getting the following message in DUMP.

"Unable to interpret " 2,000.00 " as a number."

Regards

Nishant

Read only

0 Likes
1,896

Try this code:

REPORT zh_test1 NO STANDARD PAGE HEADING.

data: v_val type p decimals 2 value '2000.00',

v_int type i,

v_char(10).

write:/ v_val.

v_int = v_val.

write:/ v_int.

v_char = v_int.

write:/ v_char.

REgards,

Ravi

Read only

0 Likes
1,896

guys,

number is " 2,000.00 "

and NOT "2000.00"

...there's a comma as well

Read only

Former Member
0 Likes
1,896

Hi,

check this..

REPORT  ZTEST_NUMBER                            .

data: number1(10) type p decimals 3,
      number(10) type n.


      number1 = '2000.000'.
     move number1 to number.
     write number1.
     write number.

Regards

vijay

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,897

You must first get rid of the comma, then move to an integer field.



report zrich_0001.


data: c(15) type c value '2,000.00'.
data: i type i.

translate c using ', '.
condense c no-gaps.

i = c.
write:/ i.

Regards,

Rich Heilman

Read only

0 Likes
1,896

Thanks a lot Rich.

Read only

0 Likes
1,896

Hi Nishant,

PLease note that Rich's code will work for only in countries where , is the thousands separator and '.' for decimal separator.

In some countries (JAPAN) the , is for decimals.

So take care before you implement this code.

Regards,

Ravi

Read only

Former Member
0 Likes
1,896

Hi Nishant,

Message was edited by: Manoj Gupta