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
4,560

Hi,

I'm having problem when converting a float variable to char - it seems like the float value is automatically rounded into the char variable, but I don't want that.

Does anybody know a wafunction or a way of avoiding this convertion round?

Thanks,

Nuno Afonso

1 ACCEPTED SOLUTION
Read only

Former Member
1,610
this should solve 

REPORT YCHATEST.

DATA : V_FLOAT TYPE F VALUE '2456.5678912',
       V_CHAR(25),
        P10_4(10)        TYPE P DECIMALS 8.

CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
  EXPORTING
    FLOAT_IMP  = V_FLOAT
    FORMAT_IMP =  P10_4
    ROUND_IMP  = ' '
  IMPORTING
    CHAR_EXP   = V_CHAR.

WRITE : V_CHAR.
7 REPLIES 7
Read only

Former Member
0 Likes
1,610

use this CEVA_CONVERT_FLOAT_TO_CHAR

Read only

0 Likes
1,610

Hi,

I've tried to use this function, but I get no results... Can you please help me with the input parameters?

Read only

0 Likes
1,610

Hi

use above FM FLTP_CHAR_CONVERSION

and pass these values

DECIM 15/ per the req

EXPON 0

INPUT 11.11111111111

IVALU SPACE

MASKN SPACE

Regards

Shiva

Read only

0 Likes
1,610

With the input parameters you gave me...

Error in ASSIGN: Memory protection error

The current program "SAPLSCFL " uses the ASSIGN statement.

However, the offset of the segment (536) plus the length (1)

is greater than the length of the segment (536).

This is not allowed.

Read only

0 Likes
1,610

Hi

i tested the same and it is working for me.

please check the input parameter for u i am having . for decimals

Regards

Shiva

Read only

Former Member
0 Likes
1,610

Hi

use FM

FLTP_CHAR_CONVERSION

FLTP_CHAR_CONVERSION_FROM_SI

Regards

Shiva

Read only

Former Member
1,611
this should solve 

REPORT YCHATEST.

DATA : V_FLOAT TYPE F VALUE '2456.5678912',
       V_CHAR(25),
        P10_4(10)        TYPE P DECIMALS 8.

CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
  EXPORTING
    FLOAT_IMP  = V_FLOAT
    FORMAT_IMP =  P10_4
    ROUND_IMP  = ' '
  IMPORTING
    CHAR_EXP   = V_CHAR.

WRITE : V_CHAR.