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

Data Type conversion

Former Member
0 Likes
1,259

Hi experts,

I have a char field with value 1,000.00

i need to copy this to a currency field.

how to achieve this?

10 REPLIES 10
Read only

Former Member
0 Likes
1,191

Hi,

try to copy it to a field of type P decimal 2. then copy it to currency from this field. I cannot check this as i dont have access to sap at this time.

thanks.

Read only

former_member226419
Contributor
0 Likes
1,191

Hi,

Hi,

Try moving it to NEWR TYPE field

DATA :

     VAL1 TYPE CHAR10 VALUE '1000.00',

     VAL2 TYPE NETWR.

VAL2 = VAL1.

WRITE : / VAL1,

          VAL2.

Regards

Sumeet

Read only

sivaganesh_krishnan
Contributor
0 Likes
1,191

HI dhivya,

Try moving the char value to currency field .

DATA :

      VAL1 TYPE CHAR10 VALUE '1000.99',

      VAL2 TYPE NETWR.  "Currency field

VAL2 = VAL1.

WRITE : / VAL1,

           VAL2.

Or

try passing the string value directly in the function module CHAR_FLTP_CONVERSION , you will get the currency value in FLSTR parameter.

Regards,

sivaganesh.

Read only

0 Likes
1,191

data type NETWR works only if the value is w/o thousands separator.

eg: if the value is like '1000.99'

but if the value is like '1,000.99' it gets to dump.

thanks.

Read only

Former Member
0 Likes
1,191

Hi Dhivya,

Use FM HRCM_STRING_TO_AMOUNT_CONVERT pass decimal separator and thousand separator (Ex: '.' and ',')

Thanks

Siddhu

Read only

0 Likes
1,191

Function module HRCM_STRING_TO_AMOUNT_CONVERT does the work.

thanks

Read only

Former Member
0 Likes
1,191

use this FM HRCM_STRING_TO_AMOUNT_CONVERT

pass the string , thousand separator,decimal separator and if it is currecy pass currecy key WAERS.

Read only

0 Likes
1,191

Function module HRCM_STRING_TO_AMOUNT_CONVERT does the work.

thnks.

Read only

0 Likes
1,191

Why to use a function module included in SAP HR module to process a simple task as to convert a character-based value into a decimal value? Maybe this function module is not available in every SAP system.

My recommendation is to use other more general function or procedure or do it manually using standard ABAP constructions.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,191

Why to use a function module included in SAP HR module to process a simple task as to convert a character-based value into a decimal value?

Lack of common sense may be

I could write a simple ABAP routine for this purpose; but alas - "the end justifies the means"

Cheers,

Suhas