Application Development 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: 

TYPE CONVERSION FLOAT TO CHAR

Former Member
0 Kudos

I HAVE A VARIABLE OF TYPE FLOAT WITH VALUE : 3.339000000000000E+02

I WANT TO CONVERT THE VALUE INTO A VARIABLE TYPE CHAR(30).

AND THE EXPECTED RESULT VALUE IS '333.9'

HOW DO I DO IT.

9 REPLIES 9

former_member598013
Active Contributor
0 Kudos

Hi Ravinder

Use the Function Module: CEVA_CONVERT_FLOAT_TO_CHAR

&********* Reward Point if helpfull******************&

Former Member
0 Kudos

Hi Ravinder,

Please check this thread for the answer :

[;

Regards

Hemant Khemani

0 Kudos

Tried the FM but no results..........can someone tell how to use the FM .......the parameters that I have to pass....detaily please...

I see there are four IMPORT parameters :

where should :'3.339000000000000E+02' sit in those parameters.

0 Kudos

Hi ravinder,

Please go through the link for the Thread I posted above you will get the answer for sure.

Regards

Hemant Khemani

former_member705122
Active Contributor
0 Kudos

Hi,

Try this,

CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
  EXPORTING
    float_imp  = w_float            "Feld TYPE F
    format_imp = w_number           "Field Format
    round_imp  = ' '                "Round off
  IMPORTING
    char_exp   = w_character.       "Feld TYPE C

Regards

Adil

Former Member
0 Kudos

Can someone make changes in this code : So that I can use it

data : w_float type f value '3.339000000000000E+02',

w_character type ausp-atwrt,

w_number type f.

CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'

EXPORTING

float_imp = w_float "Feld TYPE F

format_imp = w_number "Field Format

round_imp = ' ' "Round off

IMPORTING

char_exp = w_character. "Feld TYPE C

0 Kudos

Hi ravinder,

Please use this code :

data : w_float type f value '3.339000000000000E+02',

w_character type ausp-atwrt,

w_number(10) TYPE P DECIMALS 1.

CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'

EXPORTING

float_imp = w_float "Feld TYPE F

format_imp = w_number "Field Format

round_imp = ' ' "Round off

IMPORTING

char_exp = w_character. "Feld TYPE C

Write : w_character.

Output : 333.9

Reward points if helpful.

Regards

Hemant Khemani

Former Member
0 Kudos

Hi

I m also facing this problem.

you should take float value for calulation as its.

For Out put display you should convert as a character format.

Example

data : a(20),

data : b(5),

data : n type f.

n = 3.3330000000E+02.

a = n.

b = a.

Output : 3.33

Former Member

a simple method to convert

DATA LV_F TYPE F.

LV_F = '3.339000000000000E+02'.

DATA LV_P(12) TYPE P DECIMALS 2.

LV_P = LV_F.

DATA LV_I TYPE I.

LV_I = LV_F.