2007 Feb 22 7:37 PM
Hi,
I want to convert numbers like 12-34*56.78/90(248) into 1234567890248
I just want to remove all the other characters/special charaters out of a number. I just want to have only the digits 0-9.
Can anyone let me know whether there is any easy way to do or function modules available for taking special characters out of a number.
Thanks.
Uma.
2007 Feb 22 8:03 PM
Hi Uma,
Please try this.
REPORT ZTEST.
DATA: FIELD1(20) TYPE C VALUE '12-34*56.78/90(248)',
LENGTH TYPE I.
LENGTH = STRLEN( FIELD1 ).
DO LENGTH TIMES.
IF FIELD1(1) NA '1234567890'.
MOVE SPACE TO FIELD1(1).
SHIFT FIELD1 LEFT CIRCULAR.
ELSE.
SHIFT FIELD1 LEFT CIRCULAR.
ENDIF.
ENDDO.
CONDENSE FIELD1 NO-GAPS.
WRITE FIELD1.Regards,
Ferry Lianto
Hi,
I want to convert numbers like 12-34*56.78/90(248) into 1234567890248
I just want to remove all the other characters/special charaters out of a number. I just want to have only the digits 0-9.
Can anyone let me know whether there is any easy way to do or function modules available for taking special characters out of a number.
Thanks.
Uma.
2007 Feb 22 7:50 PM
2007 Feb 22 7:52 PM
Hi Uma,
Check the follwoing function modules:
TELNUMBER_REMOVE_SPECIAL_CHAR
SX_NUMBER_REMOVE_CHAR
Ashven
2007 Feb 22 7:56 PM
data: v_number type SP_TELNO.
v_number = '12-34*56.78/90(248)'.
CALL FUNCTION 'TELNUMBER_REMOVE_SPECIAL_CHAR'
CHANGING
telnumber = v_number
.
Output = '1234567890248'.
Thanks,
Santosh
2007 Feb 22 8:04 PM
Hi Santosh,
Thanks for the help. I tried the function module with your code example also, it is not taking out the character '*' alone.
It's giving output as '1234*567890248'.
Thanks.
2007 Feb 22 8:13 PM
Hi Uma,
Of it is not working for it then to remove * you can use REPLACE satement.
REPLACE ALL OCCURRENCES OF '*' IN v_number WITH ''.
CONDENSE v_number NO-GAPS.
WRITE / v_number.
Asvhen
2007 Feb 22 8:15 PM
It works for me. Are you declaring the variable as data: v_number type SP_TELNO.
You can just try executing the FM 'TELNUMBER_REMOVE_SPECIAL_CHAR' in SE37 also by giving the value '12-34*56.78/90(248)'.
The output it gives is 1234567890248.
Thanks,
Santosh
Thanks,
Santosh
Message was edited by:
SKJ
2007 Feb 22 8:30 PM
2007 Feb 22 8:03 PM
Hi Uma,
Please try this.
REPORT ZTEST.
DATA: FIELD1(20) TYPE C VALUE '12-34*56.78/90(248)',
LENGTH TYPE I.
LENGTH = STRLEN( FIELD1 ).
DO LENGTH TIMES.
IF FIELD1(1) NA '1234567890'.
MOVE SPACE TO FIELD1(1).
SHIFT FIELD1 LEFT CIRCULAR.
ELSE.
SHIFT FIELD1 LEFT CIRCULAR.
ENDIF.
ENDDO.
CONDENSE FIELD1 NO-GAPS.
WRITE FIELD1.Regards,
Ferry Lianto
2007 Feb 22 8:47 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |