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

Decimals...

Former Member
0 Likes
840

Hi Gurus,

I have to convert a value from a table to a decimal....Let me sight an example here...

If the value 100000 is found in the table it corresponds to 1000.00,

If the value in the table is 23456789, it corresponds to 234567.89.

Is there any way to convert the variable into the way I want..If so, please mention it.

Cheers,

Sukumar..

1 ACCEPTED SOLUTION
Read only

rodrigo_paisante3
Active Contributor
0 Likes
807

Hi,

data: hwbis type vbwf09-hwbis,

value(16) type p DECIMALS 2.

SELECT SINGLE HWBIS

INTO HWBIS

FROM VBWF09.

value = hwbis / 100.

write value.

Regards

7 REPLIES 7
Read only

rodrigo_paisante3
Active Contributor
0 Likes
807

Hi,

use a loop into wa... endloop, like this:

loop at table into wa.

wa-value = wa-value / 100.

modify table from wa.

endloop.

This will put decimals to the value. Declare wa-value type compatible to work.

Hope it help.

Read only

0 Likes
807

Hi,

Thanks for the quick reply....

SELECT SINGLE HWBIS INTO HWBIS FROM VBWF09 WHERE WFVAR = '0002'.

Here HWBIS has the value 100000, it should be converted to 1000.00 and if it has 23456789, it should be converted to 234567.89.

Cheers.....

Read only

0 Likes
807

Sukumar,

Try this...

write : HWBIS  USING EDIT MASK 'RR_______.__'.

write : HWBIS  USING EDIT MASK 'RR___,___,___.__'. "With Commas and Decimal.

Hope this helps..

Chandra.

Read only

rodrigo_paisante3
Active Contributor
0 Likes
808

Hi,

data: hwbis type vbwf09-hwbis,

value(16) type p DECIMALS 2.

SELECT SINGLE HWBIS

INTO HWBIS

FROM VBWF09.

value = hwbis / 100.

write value.

Regards

Read only

0 Likes
807

<REMOVED BY MODERATOR>

data: num(7) type n,

str type string,

str1 type string.

num = '1234567'.

concatenate num1(5) '.' num5(2) into str.

write str.

Edited by: Alvaro Tejada Galindo on Mar 25, 2008 5:07 PM

Read only

Former Member
0 Likes
807

Dear Sukumar,

My recommendations:

First thing to do: check if your field contains ONLY numbers: if <field> CO '0123456789'.

if this check is OK, do simply the following:

data: in type string. "to be converted value

data: amount type p decimals 2. "converted value

amount = in.

amount = amount / 100.

write: / 'Input:', in, ', Converted 2 Decimal value:', amount.

Hope it helps. Your request can be solved with simple commands.

Heinz

Read only

Former Member
0 Likes
807

Hi

Please try the following code.

tables VBWF09 .

types : begin of ty_VBWF09,

HWBIS(16) type c,

end of ty_vbwf09.

data : i_vbwf09 type table of ty_vbwf09,

wa_vbwf09 type ty_vbwf09.

data : length type i,

limiter type i .

select hwbis from vbwf09 into table i_vbwf09.

loop at i_vbwf09 into wa_vbwf09..

condense wa_vbwf09-hwbis.

length = strlen( wa_vbwf09-hwbis ) - 2.

limiter = length - 1.

concatenate wa_vbwf09-hwbis0(limiter) ',' wa_vbwf09-hwbislimiter(2) into wa_vbwf09-hwbis.

modify i_vbwf09 from wa_vbwf09.

write: / wa_vbwf09-hwbis.

endloop.

Note: Please do consider the length of the field. Actually the field length in the table is 15 with data type NUMC but we cannot satisfy the requirement using the same data type . so i took a variable with length 16 and added single ',' making the length 16 with data type Char.

<REMOVED BY MODERATOR>

Thanks and Regards.

Edited by: Ammavajjala Narayana on Mar 25, 2008 11:50 PM

Edited by: Alvaro Tejada Galindo on Mar 25, 2008 7:25 PM