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

how to remove trailing zero

Former Member
0 Likes
1,885

HI All ,

Could anyone please let me know how to remove trailing zero from my output or hw to decl data type of variable l_div ...so that zero wont come to output.

REPORT Y_REPORT2 .

data : l_string1(10) type n,

l_div type float.

l_string1 = 220.

l_div = l_string1 / 100 .

write l_div.

Output : 2.200000000000000E+00

Desired output : 2.2

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,327

why dont u try it with packed data type and give the number of decimals required.

10 REPLIES 10
Read only

Former Member
0 Likes
1,327

Hello,

Do like this.



DATA : L_STRING1(10) TYPE N,
L_DIV TYPE P DECIMALS 2. " check here
L_STRING1 = 220.
L_DIV = L_STRING1 / 100 .
WRITE L_DIV.

Vasanth

Read only

Former Member
0 Likes
1,328

why dont u try it with packed data type and give the number of decimals required.

Read only

0 Likes
1,327

Hi ,

Could you please explain me more abourt that .

Thanks in advacnce

Read only

0 Likes
1,327

put it as

data : i_div type p decimals 2(or whatever u desire).

Message was edited by:

sheldon barretto

Read only

0 Likes
1,327

Hi Sharma,

data : l_string1(10) type n,
<b>l_div type p decimals 1.</b>
l_string1 = 220.
l_div = l_string1 / 100 .
write l_div.

Regards

Aneesh.

Read only

0 Likes
1,327

Hi All ,

That is working fine now ,Could you please let me know also

l_string1 = 220 instead of this If I will pass 220.00

like this l_string1 = 220.00

Then what data type I have to defined for l_string1 ?

Thanks for your time & effort..

Read only

0 Likes
1,327

Hi Sharma,

data : l_string1 type p,
l_div type p decimals 1.
l_string1 = '220.00' .
l_div = l_string1 / 100 .
write l_div.

Thanks

Aneesh.

Read only

0 Likes
1,327

Hi All ,

Thanks for your help .

Points rewarded ...

Regards

Rahul

Read only

Former Member
0 Likes
1,327

why dont you try using packed decimal data type.

Read only

Former Member
0 Likes
1,327

If you look at the help on WRITE :

WRITE l_div EXPONENT 0 DECIMALS 2.

Will show as 2.20