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

How to convert char value ?

Former Member
0 Likes
1,518

Hi All,

I need to assign/convert one char value say 19000000.85 to a varible defined as char type,length 14 with decimal 0 value, for which below code i wrote:

data: item_value like zstruct-value. (here zstruct is structure and field "value" is of type c lenth 14 dec 0)

data:p_float type f,

p_packed type p decimals 2,

w_char(18) type c.

move item_value to p_float.

p_packed = p_float.

w_char = p_packed.

move w_char to item_value .

The value i am getting in debugg is w_char = 19000000.85(correctly coming) but while executing last move statement value of "item_value" is coming as 19000000 (no decimal val).I want the value of "item_value " should be 19000000.85 .How to convert this value?

Thanks

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
993

Simply use


condense w_char no-gaps.  " <<<< Use this statement
move w_char to item_value

Hi All,

I need to assign/convert one char value say 19000000.85 to a varible defined as char type,length 14 with decimal 0 value, for which below code i wrote:

data: item_value like zstruct-value. (here zstruct is structure and field "value" is of type c lenth 14 dec 0)

data:p_float type f,

p_packed type p decimals 2,

w_char(18) type c.

move item_value to p_float.

p_packed = p_float.

w_char = p_packed.

move w_char to item_value .

The value i am getting in debugg is w_char = 19000000.85(correctly coming) but while executing last move statement value of "item_value" is coming as 19000000 (no decimal val).I want the value of "item_value " should be 19000000.85 .How to convert this value?

Thanks

3 REPLIES 3
Read only

Former Member
0 Likes
993

Hi,

check this function module

Amount to string:

CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'

EXPORTING

betrg = 3000

WAERS = 'DKK'

  • NEW_DECIMAL_SEPARATOR =

  • NEW_THOUSANDS_SEPARATOR =

IMPORTING

STRING = slam

.

OR

DATA: L_AMOUNT LIKE BSEG-DMBTR,

L_AMOUNT_STRING(15) TYPE C.

  • Find 1000 seperator. If decimal seperator = . then

  • 1000 seperator = , else 1000 seperator = .

L_AMOUNT = '1.00'.

WRITE L_AMOUNT TO L_AMOUNT_STRING.

IF L_AMOUNT_STRING CS ','.

P_SEP = '.'.

ELSE.

P_SEP = ','.

ENDIF.

Regards

Krishna

Read only

former_member194669
Active Contributor
0 Likes
994

Simply use


condense w_char no-gaps.  " <<<< Use this statement
move w_char to item_value

Read only

Former Member
0 Likes
993

Hi Debabrata ,


Amount to string:

CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'
  EXPORTING
    betrg                         = 3000
    WAERS                         = 'DKK'
*   NEW_DECIMAL_SEPARATOR         =
*   NEW_THOUSANDS_SEPARATOR       =
 IMPORTING
   STRING                        =  slam
          .


String to amount:

CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
  EXPORTING
    string                    = slam2
    DECIMAL_SEPARATOR         = '.'
*   THOUSANDS_SEPARATOR       =

    WAERS                     = 'HUF'
 IMPORTING
   BETRG                     = b2
* EXCEPTIONS
*   CONVERT_ERROR             = 1
*   OTHERS                    = 2

or


  L_AMOUNT = '1.00'.
  WRITE L_AMOUNT TO L_AMOUNT_STRING.


write my_amount to  l_stramount using edit mask l_edit_mask_amount.

write my_quant to l_strquant using edit mask  l_edit_mask_quant.

  WRITE P_AMOUNT_STRING TO P_AMOUNT_STRING RIGHT-JUSTIFIED.


Regards,

Prabhudas