2006 Aug 30 9:45 PM
Hi,
How can i convert a char number in char format to decimal format?.
For example:
Data: char_format(10) type c value '12,345.56'.
Data: decimal_format(10) type p decimals 2.
How should i assign it?
Thanks,
Sandeep
2006 Aug 30 10:06 PM
Try:
REPORT ztest MESSAGE-ID 00.
DATA: char_format(10) TYPE c VALUE '12,345.56'.
DATA: decimal_format(10) TYPE p DECIMALS 2.
REPLACE ALL OCCURRENCES OF ',' IN char_format WITH space.
CONDENSE char_format NO-GAPS.
decimal_format = char_format.
Rob
This just gets rid of the comma. If you have any other non-numerics in the field ($, etc.), you have to remove them as well.
Message was edited by: Rob Burbank
Hi,
How can i convert a char number in char format to decimal format?.
For example:
Data: char_format(10) type c value '12,345.56'.
Data: decimal_format(10) type p decimals 2.
How should i assign it?
Thanks,
Sandeep
2006 Aug 30 9:47 PM
nevermind don't listen to me. I need some sleep.
Message was edited by: Matt Nagel
Message was edited by: Matt Nagel
2006 Aug 30 10:26 PM
Rob is right here, you need to get rid of the commas, you can also do this using the TRANSLATE statement.
DATA: char_format(10) TYPE c VALUE '12,345.56'.
DATA: decimal_format(10) TYPE p DECIMALS 2.
<b>translate char_format using ', '.
CONDENSE char_format NO-GAPS.</b>
decimal_format = char_format.
Regards,
Rich Heilman
2006 Aug 31 12:43 AM
hi rich,
here i have one more doubt...
suppose if the amount is comming in country specific format then how we are going to handle it
like in us --> 123.123,00
in india --> 123,123.00
then how can we convert this to num?
2006 Aug 31 12:55 AM
2006 Aug 31 1:00 AM
For example..........
report zrich_0005.
data: char_format(10) type c value '12,345.56'.
data: decimal_format(10) type p decimals 2.
data: xusr01 type usr01.
* 1.234.567,89
*X 1,234,567.89
*Y 1 234 567,89
select single * into xusr01 from usr01
where bname = sy-uname.
case xusr01-dcpfm.
when space.
translate char_format using '. '.
translate char_format using ',.'.
when 'X'.
translate char_format using ', '.
when 'Y'.
translate char_format using ',.'.
endcase.
condense char_format no-gaps.
decimal_format = char_format.
Regards,
RIch Heilman
2006 Aug 30 10:06 PM
Try:
REPORT ztest MESSAGE-ID 00.
DATA: char_format(10) TYPE c VALUE '12,345.56'.
DATA: decimal_format(10) TYPE p DECIMALS 2.
REPLACE ALL OCCURRENCES OF ',' IN char_format WITH space.
CONDENSE char_format NO-GAPS.
decimal_format = char_format.
Rob
This just gets rid of the comma. If you have any other non-numerics in the field ($, etc.), you have to remove them as well.
Message was edited by: Rob Burbank
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |