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

Function to convert a float

Former Member
0 Likes
1,202

Hi,

Someone know which FM can I used to convert a float to a numeric??

Thanks

1 ACCEPTED SOLUTION
Read only

ChristianFi
Active Participant
0 Likes
1,132

Usually there is no explicit conversion required. Just move it to a type N or P field to get the desired result.

Christian

8 REPLIES 8
Read only

ChristianFi
Active Participant
0 Likes
1,133

Usually there is no explicit conversion required. Just move it to a type N or P field to get the desired result.

Christian

Read only

0 Likes
1,132

Hi,

No, it doesn't convert.

I have a field in a query like N but the field of the table is float so when it will be display, display it like 8.00000000+E01 and not 180

Read only

0 Likes
1,132

Hi,

try that :

data f1 type f value 180.
data f2(10)  type n.

move f1 to f2.

write: / f1, f2.

*result*
*  1,8000000000000000E+02 0000000180

Read only

andreas_mann3
Active Contributor
0 Likes
1,132

Hi Laura,

i think you need no fm

lokk F1 to move:

from docu:

The source field is converted into a packed number. The packed number is then converted into a numeric text field (see corresponding table).

Andreas

Read only

Former Member
0 Likes
1,132

hi laura

use function module:MURC_ROUND_FLOAT_TO_PACKED

and if it works please reward the poitn and if u need any help in this again just mail back

thanks

Read only

0 Likes
1,132

Hi,

I tried to use that function but have an error

Errores tiempo ejecucióCALL_FUNCTION_CONFLICT_TYPE

Excepción CX_SY_DYN_CALL_ILLEGAL_TYPE

I don't know if I used it correctly

DATA: v_conf_tc TYPE ibco2_instance_tab2,

v_atinn_tc LIKE ibvalue0-atinn,

v_values_tc LIKE ibvalue0,

numerico type n.

CALL FUNCTION 'MURC_ROUND_FLOAT_TO_PACKED'

EXPORTING

IF_FLOAT = v_values_tc-atflv

IF_SIGNIFICANT_PLACES = 15

IMPORTING

EF_PACKED = numerico

  • EXCEPTIONS

  • OVERFLOW = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

WRITE numerico TO v_atwrt_tc.

I hope you can help me

Thanks

Read only

0 Likes
1,132

change the declation

numerico type n.

to

numerico(16) type p decimals 2.

Regards

Raja

Read only

0 Likes
1,132

actually the dump analysis would tell you which parameter was passed incorrect. i guess its numerico. confirm it with your dump analysis.

Regards

Raja