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

Data Type Conversion

Former Member
0 Likes
837

Hi Everybody,

Could u please tell me how to convert Floating Point Data Type content to Character Type content?????

For Ex.

Floating Point Number = 1.35100000E+02

It should be converted to Character type value = 135.1

Thanks in Advance

Points will be rewarded to Proper answer.

4 REPLIES 4
Read only

Former Member
0 Likes
667

Hi,

Just move the floating pt field to char field before transfering data to write statement.

Regards

Srimanta

Read only

Former Member
0 Likes
667

DATA : v_char(20),

v_float TYPE F value '203.98'.

MOVE : v_float to v_char.

WRITE : v_char.

OR

CALL FUNCTION 'FLTP_CHAR_CONVERSION_FROM_SI'

EXPORTING

char_unit = 'EA'

unit_is_optional = 'X'

decimals = 0

exponent = 0

fltp_value_si = lv_atwrt_temp

indicator_value = 'X'

masc_symbol = '_'

IMPORTING

char_value = lv_atwrt

EXCEPTIONS

no_unit_given = 1

unit_not_found = 2

OTHERS = 3.

Or

CALL FUNCTION 'FLTP_CHAR_CONVERSION'

EXPORTING

DECIM = QAMV-STELLEN

INPUT = QAMR-MITTELWERT

IMPORTING

FLSTR = V_CHAR.

SHIFT V_CHAR LEFT DELETING LEADING SPACE .

Reward points..

Read only

Former Member
0 Likes
667

Try this logic

parameters: a(16).

data: a1 type f.

a1 = a.

if sy-subrc eq 0.

write:/ 'india'.

endif.

OR

Use FM CONVERSION_EXIT_ALPHA_INPUT.

OR

If usefull reward points helpfull.....

Read only

Former Member
0 Likes
667

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

Reward If helpfull,

Naresh.