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 convert float into %

Former Member
0 Likes
683

Hi All,

My issue is i have to convert one float type value into %. Means i m dividing two values of int4 type and the result i sstoring in one float data type variable.

I want to display the result value is with %.

Ex:DATA: n1 TYPE i,

n2 TYPE i,

r1 TYPE f.

n1 = 8.

n2 = 9.

r1 = ( n1 / n2 ) * 100.

write:/ r1.

the result is 8.88 .

But my requirement is to display this 8.88 as 8.88%..

plz help me in this matteer, this is support issue i have to resolve today only..

Thanx in advance,

jagadish.T

4 REPLIES 4
Read only

Former Member
0 Likes
658

Hi

use

concatinate r1 and '%' into r2.

write : r2.

reward if helpful

vivekanand

Read only

former_member188827
Active Contributor
0 Likes
658

DATA: n1 TYPE i,

n2 TYPE i,

r1 TYPE f.

data:zch(10) type c.

n1 = 8.

n2 = 9.

r1 = ( n1 / n2 ) * 100.

move r1 to zch.

concatenate zch '%' into zch.

write:/ zch.

plz reward points if dis helps

Read only

former_member194152
Contributor
0 Likes
658

Hi,

For that you have first move 8.88(output) to a character field (which newly declare in program) and then concatenate that field with '%' sign.

Remember concatenate only work for character field.

*Reward if helpful

Regards

Gagan

Read only

Former Member
0 Likes
658

hi,

try this code:

DATA: n1 TYPE i,

zvar type string,

zc type string,

zlen type i,

n2 TYPE i,

r1 TYPE f.

n1 = 8.

n2 = 9.

r1 = ( n1 / n2 ) * 100.

move r1 to zvar.

zlen = strlen( zvar ).

zc = zvar+0(3).

concatenate zc '%' into zc.

write zc.

output: 8.8%.

do reward points if it helps.

rgds.