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 data

Former Member
0 Likes
3,354

hi

could u help me out.

i am trying to display sum of cdiff column from table imrg.

but it display something like this 3.600000000000000E+06. i guess its bcoz of float data type. could u tell me how can i convert it to char.

i heard that thier is function module to convert this kind of data. could u tell me which is tht.

thnks in advance

5 REPLIES 5
Read only

Former Member
0 Likes
1,691

you can't convert float data. better use packed data. TYPE P.

that can be changed to string easily bys using uppack statement.

refer F1 help for UNPACK statement.

Reward if useful

Regards

ANUPAM

Read only

former_member386202
Active Contributor
0 Likes
1,691

Hi,

Use THis FM

&----


*& Form sub_fltp_to_char *

&----


  • This form converts cycle from floating to character format *

----


FORM sub_fltp_to_char .

*--Local constants

CONSTANTS: lc_dec TYPE i VALUE 0.

*--Clear Variable

CLEAR v_cycle.

IF NOT v_unit IS INITIAL.

*--Call function module to convert cycle & offset from floating to

  • character

CALL FUNCTION 'FLTP_CHAR_CONVERSION_FROM_SI'

EXPORTING

char_unit = v_unit

decimals = lc_dec

fltp_value_si = v_offset

indicator_value = c_check

IMPORTING

char_value = v_cycle

EXCEPTIONS

no_unit_given = 1

unit_not_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF. "IF NOT v_offset IS INITIAL.

ENDFORM. "sub_fltp_to_char

Regards,

Prashant

Read only

Former Member
0 Likes
1,691

data: a(20) type c.

a = '14,23,680'.

*Replace ',' in a with space.

replace all OCCURRENCES of ',' in a with space.

condense a.

write:/ a.

If usefull reward points helpfull.....

Read only

Former Member
0 Likes
1,691

to convert float data to int their is no need use any function module just assign float type to int type in your program for e.g if you have float column in table then assing that column to int column in internal table in your program.

Thanks,

SUDHIR MANJAREKAR

Read only

Former Member
0 Likes
1,691

Try to use next FM 'CEVA_CONVERT_FLOAT_TO_CHAR'.

You can try this code:

DATA:

lv_measure TYPE imrc_recdv,

lv_format(16) TYPE p DECIMALS 1,

lv_value(16) TYPE c.

CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'

EXPORTING

float_imp = lv_measure

format_imp = lv_format

IMPORTING

char_exp = lv_value.