05-12-2005 7:47 PM
hi,
I have the data(amount) taken from currency field it has the amount value like (1,456.78) I need to remove the comma and periods here just get the number (145678) in the char format. How can I do this?
Thanks for your help in advance.
Santhosh
05-12-2005 8:00 PM
05-12-2005 7:57 PM
Here is a way.
WRITE v_amountfield CURRENCY v_currencykey TO v_charfield NO-GROUPING.
TRANSLATE v_charfield USING '. '.
CONDENSE v_charfield NO-GAPS.
Srinivas
05-12-2005 8:00 PM
05-12-2005 8:23 PM
05-12-2005 8:38 PM
Also, you may want to wrap the REPLACE statements in a WHILE loop. If you number is like 1,513,561.84 the code will only get rid of one of the commas. Do something like this.
data: x(20) type c value '1,511,234.78'.
while x ca ',.'.
replace ',' with space into x.
replace '.' with space into x.
endwhile.
condense x no-gaps.
Regards,
Rich Heilman
05-12-2005 9:22 PM
Hi Santhosh,
The reason why I gave you the combination of WRITE and TRANSLATE is that it takes care of the following
1. WRITE with CURRENCY will take care of the number of decimal places to be used.
2. WRIT with NO GROUPING will take care of removing the separators for thousands etc.
3. TRANSLATE takes care of replacing all your '.'s or ','s with spaces.
Finally CONDENSE NO GAPS gets rid of the spaces.
Just food for thought.
05-12-2005 9:49 PM