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

Convert Float to Char

Former Member
0 Likes
5,193

Hii

Please suggest me a way to convert float to char. Though there is a function modules for this in SAP for eg one called "CEVA_CONVERT_FLOAT_TO_CHAR" but i could not figure out how to fill up the parameters .

Please suggest a way for this conversion.

Ajitabh Pradhan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,305

Hi ajitah pradhan,

You can directly convert a float to charecter by just assigning them in your report.

For eg.

program:

data: f type f.

data: c(24).

f = 20.

write : f.

c = f.

write: / c.

output:

2,0000000000000000E+01

2.0000000000000000E+01

The charecter should be of 24 in length.

Else the no. of zero reduces.

hope this helps you.

Regards,

Vivek.

9 REPLIES 9
Read only

Former Member
0 Likes
2,305

Hello,

please try Function FLTP_CHAR_CONVERSION.

Regards

Frank Brackmann

Read only

0 Likes
2,305

Hii

I have value in the form of 1.000000000E+05 to be converted to 100 .

How can such values be converted ?

Regards

Ajitabh

Read only

0 Likes
2,305

Hi Ajitabh,

This works for me.

REPORT ZRT_TEST.

data: f type f value '1.000000000E+05'.

data: i type i.

write:/ f.

i = f.

write:/ i.

Regards,

ravi

Read only

0 Likes
2,305

Thanks Ravi,

We got into to omuch complexity for such a small solution ....

Regards

Ajitabh

Read only

0 Likes
2,305

Hi Ajit,

Please reward the helpful answers.

Thanks,

Ravi

Read only

Former Member
0 Likes
2,305

Hi Ahitabh,

Why to use an FM for that?

Just assign the float value to a normal Char type variable of length = output length of the float variable.

v_char = v_float.

Regards,

Ravi

Read only

Former Member
2,305

Hi Ajitabh,

1. i dont know whether i understood ur question properly or not.

We can use simple =

2. try this code (just copy paste)

report abc.

data : f type p decimals 5.

data : s(15) type c.

f = '41.35666'.

s = f.

write 😕 f.

write 😕 s.

regards,

amit m.

Read only

0 Likes
2,305

Hi again,

1. use like this.

REPORT abc.

DATA : f TYPE f.

DATA : s(15) TYPE c.

f = '41'.

CALL FUNCTION 'FLTP_CHAR_CONVERSION'

EXPORTING

DECIM = 2

  • EXPON = 0

input = f

  • IVALU = ' '

  • MASKN = ' '

IMPORTING

flstr = s

.

WRITE 😕 f.

WRITE 😕 s.

regards,

amit m.

Read only

Former Member
0 Likes
2,306

Hi ajitah pradhan,

You can directly convert a float to charecter by just assigning them in your report.

For eg.

program:

data: f type f.

data: c(24).

f = 20.

write : f.

c = f.

write: / c.

output:

2,0000000000000000E+01

2.0000000000000000E+01

The charecter should be of 24 in length.

Else the no. of zero reduces.

hope this helps you.

Regards,

Vivek.