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

Conversion from char to pack value

Former Member
0 Likes
1,337

Hi,

I am trying to change exponetial value to pack decimals 2 value . I used following FM

'CHAR_FLTP_CONVERSION'

CHAR_PACK_CONVERSION' this is showing length is longer.

ex.  data lv_char type char22.

       data lv_dec type p decimals 2.

lv_char = ' 0.000000000000000E+01'.

now i want to change it decimal value.

Please give me some solution.


Regards,

Durga.

5 REPLIES 5
Read only

FredericGirod
Active Contributor
0 Likes
984

Hi,

did you check with the statement WRITE ... TO ... ?

regards

Fred

Read only

ThangaPrakash
Active Contributor
0 Likes
984

Hello Durga,

Try with the below code.

data:lv_temp(128),

        lv_value type zflpt. " zfltp domian is FLTP

lv_value = '2.6000000000000003E-03'.

lv_temp = lv_value.

   ls_convert-type = 'P'.

   ls_convert-length = 13.

   ls_convert-decimals = 6.

   ls_convert-ddic_leng = 13.

   ls_convert-sign = c_true.

CALL FUNCTION 'RS_CHECK_CONV_EX_2_IN_NO_DD'

     EXPORTING

       input_external               = lv_temp

       descr                           =   ls_convert

     IMPORTING

       input_i_format               = lv_temp

lv_temp has value 0.002600

Regards,

Thanga

Read only

0 Likes
984

Hi Thanga,

data:lv_temp(128),

         lv_value type QMAX_VAL. " zfltp domian is FLTP

lv_value = '2.6000000000000003E-03'.

lv_temp = lv_value.

data: ls_convert type   RSCONVERT.

    ls_convert-type = 'P'.

    ls_convert-length = 13.

    ls_convert-decimals = 6.

    ls_convert-ddic_leng = 13.

    ls_convert-sign = '+' .

CALL FUNCTION 'RS_CHECK_CONV_EX_2_IN_NO_DD'

      EXPORTING

        input_external               = lv_temp

        descr                           =   ls_convert

      IMPORTING

        input_i_format               = lv_temp.


I am doing this but i am getting errror "Entry 2.0000000000000000E-03  is too long" Please correct me where i am doing wrong.

Regards,

Durga.

Read only

Former Member
0 Likes
984

Hi Durga,

you need define a variable type F.

data: lv_f type f.

MOVE lv_char TO lv_f.

lv_dec = lv_f.

regards

Archer

Read only

Former Member
0 Likes
984

Hi Durga,

As per your requirement we cannot move the char to packed decimal 2. Because lv_char is char22 and lv_dec is type p decimal 2. Where lv_char = ' 0.000000000000000E+01'. cannot be recognised as number. So when moving from lv_char to lv_dec it occurs runtime error.

Regards,

Vineesh.