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

value from floating point

Former Member
0 Likes
765

Hi all,

I have a field <field> of type FLTP and length 16. This field has a value 4.650000000000000E+01. I want to print this value as 46.5. How can I do this.

Waiting for replies. Thanks

7 REPLIES 7
Read only

Former Member
0 Likes
633

data val(16).

write <field> to val.

condense val.

hope this will work

Read only

Former Member
0 Likes
633

Hi Raju,

Take another variable of TYPE P DECIMALS 1 and MOVE fltp to type p.

DATA V_FLTP TYPE F VALUE '4.650000000000000E+01'.

<b>DATA V_PD TYPE P DECIMALS 1.

V_PD = V_FLTP

WRITE V_PD. -


> 46.5.</b>

V_PD displays leading blanks and displays 46.5,BUT if you need with out leading blanks then take a character variable of length 16 and move the contents of V_PD.

<b>DATA V_C(16) TYPE C.

V_C = V_PD.

CONDENSE V_C.

WRITE V_C. -


> 46.5 (W/0 leading blanks)</b>

<b>Note: Plz award all helpful answers and close the thread once problem is solved.</b>

Thanks,

Vinay

Read only

sridhar_k1
Active Contributor
0 Likes
633

If you want to show <field> in list display use

WRITE <Field> EXPONENT 0 DECIMALS 1.

Regards

Sridhar

Read only

0 Likes
633

Hi guys,

Thank you for the replies. I think I forgot to mention some thing else.

I can have any value in the field <field>. For example If I have

4.650000000000000E+01 I need 46.5 and if I have

5.000000000000000E-02 I need 0.05

in my <field>. how can I do this. Waiting...........

Read only

0 Likes
633

write v_fltp to v_char exponent 0.

shift v_char right deleting trailing '0'.

write v_char.

Regards

Sridhar

Read only

Former Member
0 Likes
633

hi,

check the below links

If u find it useful plz mark the points

Records,

Naveen

Read only

former_member183924
Active Participant
0 Likes
633

I have the same problem like you, but cannot solve it with these answers in this thread here.

My <fs> is assigned to a field of a table (dynamicly and direktly). To copy the value in <fs> to an P-Variable, it doesn't helped me...

See my code:


DATA:
      grfk_ok_code    TYPE sy-ucomm,
      grfk_values     TYPE TABLE OF GPRVAL WITH HEADER LINE,
      wa_ztab         TYPE zqm_chq,
      l_index      TYPE n,
      l_field      TYPE string,
      l_fs2p       TYPE p DECIMALS 3
      .

  FIELD-SYMBOLS:  <fs_field> TYPE ANY.

LOOP AT ztab INTO wa_ztab.

UNASSIGN <fs_field>.
    l_index = sy-tabix.
    CONCATENATE 'grfk_values-val' l_index INTO l_field.
    ASSIGN (l_field) TO <fs_field>.
    IF sy-subrc <> 0.
      RETURN.
    ENDIF.
    <fs_field> = wa_ztab-cf_dlp.
    l_fs2p     = <fs_field>.
    <fs_field> = l_fs2p.

ENDLOOP.

And I cannot use the floating point values in the grfk_value table...

Regards,

Steffen