2007 Jun 13 12:09 PM
Hi all.
I want to convert character value into numeric value
amount = (numeric type)
in_var-value = 4,000.00 (char type)
Iam getting error with below mentioned statement
amount = in_var-value.
because there is ',' in 4,000.00 .
How to remove this came ',' from this 4,000.00. is there any function module
Thanks in advance
2007 Jun 13 12:21 PM
Hi Ranjith,
You can use the following code:
data a type p decimals 3.
data b(4) type c.
b = '4,000'.
replace ',' in b with space .
condense b.
a = b.
write : / b.This will remove the ',' from the numeric value.
As for any function module that does the same, I'm not aware of it.
Regards
Anil Madhavan
Hi all.
I want to convert character value into numeric value
amount = (numeric type)
in_var-value = 4,000.00 (char type)
Iam getting error with below mentioned statement
amount = in_var-value.
because there is ',' in 4,000.00 .
How to remove this came ',' from this 4,000.00. is there any function module
Thanks in advance
2007 Jun 13 12:10 PM
2007 Jun 13 12:14 PM
hi,
I want to convert char to numeric but not from numeric to char.
2007 Jun 13 12:17 PM
hI,
data: char(10) type c value '12345.00'.
data: p type p decimals 2.
if char co '1234567890. '.
p = char.
else.
Give message
endif.
write:/
<b>*Reward points</b>
REGARDS
2007 Jun 13 12:17 PM
data : var1(10) type c,
var2(10) type n.
var1 = 'ABC123'.
var2 = var1.
write 😕 var2.
this way the non-numeric characters will be removed. See how you can modify this to suit your requirement.
2007 Jun 13 12:16 PM
Hi,
Try this:
&----
*& Form convert-string-to-number (type f, i, p)
&----
FORM convert-string-to-number
USING
value(p_string) TYPE string
CHANGING
p_number TYPE any "-- f, i, p --
p_error TYPE i.
TRY.
CLEAR p_error.
p_number = p_string. "Convert string to number.
CATCH cx_sy_conversion_no_number.
p_error = 1.
CATCH cx_sy_conversion_overflow.
p_error = 2.
ENDTRY.
ENDFORM. "convert-string-to-number
Regards,
Padmam.
2007 Jun 13 12:18 PM
Hi,
Use NUMC and then assign the NUMC to an I or P
Like this
DATA: num1(10) type n,
number(10) type p decimals 2.
num1 = in_var-value.
number = num1.
Regards,
Sesh
2007 Jun 13 12:20 PM
replace all occurrences of ',' in in_var-value with space.
condense in_var-value no-gaps.
amount = in_var-value.
regards
shiba dutta
2007 Jun 13 12:21 PM
Hi Ranjith,
You can use the following code:
data a type p decimals 3.
data b(4) type c.
b = '4,000'.
replace ',' in b with space .
condense b.
a = b.
write : / b.This will remove the ',' from the numeric value.
As for any function module that does the same, I'm not aware of it.
Regards
Anil Madhavan
2007 Jun 13 12:57 PM
Hi anil,
Thanks for your answer, it looks good, but I have found another solution as follows
REPLACE ALL OCCURRENCES OF ',' IN IN_VAR-VALUE WITH ''.
VAL5 = IN_VAR-VALUE.
it is working fine.
2007 Jun 13 12:23 PM
Hi,
You can use this function module
'C14W_CHAR_NUMBER_CONVERSION'
Pass your in_var-value in the FM and you can get the amount in numeric type.
Regards,
Sangeeta.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |