11-21-2007 8:39 PM
I am using a Currency field from SAPScript in an ABAP Program to retrieve certain values. So I am passing the currency value as text field along with the commas and decimals to the Program from the SAPscript . I need to convert this to currency format so that I could use this in the select statement. How do I achieve this?
11-21-2007 8:48 PM
Try with this code:
DATA: P_DBMTR TYPE DMBTR.
DATA: C_VALUE(20).
c_value = '123,456.78'.
* Convert to amount
replace all OCCURENCES of ',' in c_value with ' '.
condense c_value.
move c_value to P_DBMTR.
* convert back from amount to char
write: P_DBMTR to c_value.
Regards,
Naimesh Patel
11-21-2007 8:43 PM
Hi Anjana,
Declare a character variable with the same lenght as currency variable.
Just Move the currency variable value to character varaiable.
If you have any problem with comma in the currency variable just replace with ''.
Regards,
Satish
11-21-2007 8:50 PM
My main problem is conversion from character to currency. How can I remove the commas in the character field?
11-21-2007 8:51 PM
Replace Comma with '.'.
Regards,
Satish
Message was edited by:
Satish Panakala
11-21-2007 8:48 PM
Try with this code:
DATA: P_DBMTR TYPE DMBTR.
DATA: C_VALUE(20).
c_value = '123,456.78'.
* Convert to amount
replace all OCCURENCES of ',' in c_value with ' '.
condense c_value.
move c_value to P_DBMTR.
* convert back from amount to char
write: P_DBMTR to c_value.
Regards,
Naimesh Patel
11-21-2007 8:57 PM
Naimesh, I assume 'all occurences' work only in higher versions of SAP. I get a syntax error when I used this...we are still on 45B.
11-21-2007 8:58 PM
Ok than try with this:
replace ',' in c_value with ' '.
replace ',' in c_value with ' '.
replace ',' in c_value with ' '.
replace ',' in c_value with ' '.
condense c_value.
move c_value to P_DBMTR.
Regards,
Naimesh Patel
11-21-2007 9:13 PM
Thanks Naimesh and Sadish for your helpful answers. It is working now.
Anjana
02-14-2012 6:51 AM
Refer this code.....
http://theabap.blogspot.in/2012/02/character-to-currencyformat-conversion.html
Hope you will like it really...