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

Regarding Decimal

Former Member
0 Likes
1,348

Hi all,

I need to remove decimal places, wats the best way to do that,

Eg: DMBTR = 3900.00, but i just want to display as 3,900

Thanks in advance

13 REPLIES 13
Read only

Former Member
0 Likes
1,216

Hi,

define a variable from type int and move your value inside it before you give it out.

Regards

Nicole

Read only

Former Member
0 Likes
1,216

Move the values to another varaiable of data type 'I' , it will display the whole numbers.

Thanks,

Ponraj.s.

Read only

Former Member
0 Likes
1,216

data : v_DMBTR type DMBTR value '3900.00'.

write v_DMBTR decimals 0.

Read only

Former Member
0 Likes
1,216

hiii

just move values in type ' I '..it will round your values.so output will be without decimal.

reward if useful

thx

twinkal

Read only

Former Member
0 Likes
1,216

hi

You can use below code :

data : var1 type p decimasl 3 value '100.000'.

data : var2 type i.

var2 = var1.

write : var2.

O/P : 100.

Reward points

Cheers

Snehi

Read only

Former Member
0 Likes
1,216

data: v_test type p decimals 2 value '3900.00'.

data: out type p .

out = v_test .

write:/ out decimals 0.

Read only

Former Member
0 Likes
1,216

I did try to do the same , declared variable type int and tried to move the value, but wen i update the amount to internal table again it takes as 3900.00,

I am trying to avoid decimals because IDR dosent support decimal, expected result is 3,900,

but what I am getting is 390,000.

Read only

0 Likes
1,216

This problem is becouse of the veriable you are using for your internal table

it is happening like this

Value in the field of internal table is : 3900.25

now you take this to an integer value it will be 3900

But when you will update this value back to ur internal table it will be 3900.00

Just declear one more internal table with same structure just change that particular field to char or integer type loop on the first table and copy the values to secand table.

delete the first table now you use your secand table in your program for further processing.

Reward points if helpful

Regards

Bikas

Read only

Former Member
0 Likes
1,216

if you want to print dmbtr without decimal then try dmbtr(C) , C will remove decimal

Read only

Former Member
0 Likes
1,216

Hi Soyunee,

Take the value into a character type field using write statement with currency or unit depanding on the type(i think for you it should be CURRENCY )

WRITE VALUE TO L_NETP CURRENCY WAERK.

here Value = 3900.00 and L_NETP is character field of same size as VALUE.

CURRENCY WAERK is the syntax try to put it as it is.

if any problem please let me know

3,900 (For comma) depends on decimal format defind in T005X table.

Thanks & Regards

Ankur

Read only

Former Member
0 Likes
1,216

Hi Ankur,

Here is the code for clear understading,

ORIGINAL

SELECT SINGLE * FROM tcurf WHERE fcurr EQ tbl_i_vbkpf-waers

AND tcurr = tbl_i_vbkpf-hwaer.

IF sy-subrc = 0.

l_kursf = tbl_i_vbkpf-kursf * ( tcurf-tfact ) / ( tcurf-ffact ).

ENDIF.

IF tbl_i_vbkpf-waers NE 'IDR'.

tbl_i_vbsegs-dmbtr = tbl_i_vbsegs-wrbtr * g_tbl_i_vbkpf-kursf * 10.

ENDIF.

Note: Local curreny is always IDR.

with the above coding I am facing issues when the document currency is JPY, the result is multiple of 10 for the original amount coz its multiplied by 10.

MODIFIED

tbl_i_vbsegs-dmbtr = tbl_i_vbsegs-wrbtr * l_kursf.

With this JPY to IDR is fine but the result USD to IDR is multiple of 100.

Can anyone please help me on this.

Read only

0 Likes
1,216

DATA: LV_DEC TYPE P DECIMALS 2,

LV_CHAR TYPE CHAR20,

LV_NUM TYPE CHAR20,

LV_DEC1 TYPE CHAR20.

LV_DEC = '3902.00'.

LV_CHAR = LV_DEC.

SPLIT LV_CHAR AT '.' INTO LV_NUM LV_DEC1.

WRITE: LV_NUM.

Hope this helps...

Reward points if useful,

Janani

Read only

0 Likes
1,216

Hi soyunee,

you are facing this problem probably because you are multiplying value with character value try to do all manupalation ,multiplication,operation with the original type not with the character type you have taken.

and at last convert

WRITE tbl_i_vbsegs-dmbtr TO L_VALUE CURRENCY tbl_i_vbkpf-waers

stil face problem tell me exact place you are using write statement

Thanks & Regards

Ankur