cancel
Showing results for 
Search instead for 
Did you mean: 

how to format decimals in variable

Former Member
0 Kudos

Hi all .

I want to ask ; how to format decimal values. sample ;

value

40.45235435345

I want to show

40.45

how am ı doing this. I use this code :

but result is = 40.45235435345 .

[SMARTFORM|http://www.irfanmatak.com/projects/smartform.jpg]

Regards

İrfan.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi irfan,

Try like this;

data amount type p DECIMALS 5 VALUE '12.45678'.
data amount1(10) type C.
write amount to amount1 DECIMALS 2.

Now amount1 will contain 12.46, you can control the number of decimals using the decimals option in write statement.

If you are doing this in smartforms, no need for coding just use like this;

&itab-netpr(C.2)&

Here C will condense the leading spaces and .2 will restrict the value to print with 2 decimals. Give this a try and let me know if it works.

Regards

Karthik D

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks everybody I fix problem ,

DATA: GV_DEC TYPE P DECIMALS 2.

CLEAR: GV_NETWR.

GV_NETWR = LS_VBRP-KZWI5 / LS_VBRP-FKIMG.

GV_DEC = GV_NETWR.
GV_NETWR = GV_DEC.

casting and decimal 2 show in varible.

Regards.

Former Member
0 Kudos

write like this

&v_var(C.2)&

Former Member
0 Kudos

Hi

IRFAN , u can use CEIL(WF_VALUE) or FLOOR(WF_VALUE) operators.

BR

Lavanya

Former Member
0 Kudos

Hi ,Thanks for the answer but I does not work it.

CLEAR: GV_NETWR.

GV_NETWR = LS_VBRP-KZWI5 / LS_VBRP-FKIMG.

GV_NETWR = CEIL(GV_NETWR).

CONDENSE GV_NETWR NO-GAPS.

I cant do well. Please explain this solution. CEIL doing syntax error.

regards

Edited by: Irfan MATAK on Sep 15, 2008 1:07 PM