04-14-2011 11:28 AM
Hi,
I am trying to remove special character (' - single quote sign) programmatically in SAP ECC 6.0 release but could not suceed even with following different options:
DATA : quote TYPE c VALUE ''''.
1. REPLACE ALL OCCURRENCES OF REGEX '[ '' ]' in corr_string WITH space.
2. REPLACE ALL OCCURRENCES OF REGEX '[ [:punct:] ]' IN corr_string WITH space.
3. REPLACE ALL OCCURRENCES OF quote IN corr_string WITH space.
4. TRANSLATE corr_string USING ''''.
5. CONDENSE corr_string NO-GAPS.
6. REPLACE ALL OCCURRENCES OF '''' IN corr_string WITH ' '.
Second option do remove the sign but it also condense the string which should not be the case.
Is there any other method to achieve the functionality, the outcome is expected as below:
Input string: 'abc def' gh'i.
Output string: abc def ghi.
Thanks in advance,
Ni3
04-14-2011 12:02 PM
Hi,
This question sounds basic but from your question its clear that you have tried it out so let me try to help you.
Check
Replace all occurrences of `'` in lv_sentence with ` `.
or
Replace all occurrences of `'` in lv_sentence with ` `.
condense lv_sentence.
Use which ever suits your requirement.
04-14-2011 12:02 PM
Hi,
This question sounds basic but from your question its clear that you have tried it out so let me try to help you.
Check
Replace all occurrences of `'` in lv_sentence with ` `.
or
Replace all occurrences of `'` in lv_sentence with ` `.
condense lv_sentence.
Use which ever suits your requirement.
04-14-2011 12:15 PM
Venkat,
I tried both the options but result not as expected.
I am working on SAP ECC 6.0 release, is it not supporting the clearing off the single quote sign?
Regards,
Nitin.
04-14-2011 12:26 PM
Even i am in ECC 6 and this works fine for me.
DATA:lv_sentence TYPE string.
CONCATENATE 'I' `'` 'am writing a program' INTO lv_sentence.
WRITE lv_sentence.
SKIP 1.
REPLACE ALL OCCURRENCES OF `'` IN lv_sentence WITH ` `.
WRITE lv_sentence.
04-14-2011 12:40 PM
Hi,
Try the above code suggested by Keshav, it should work.
Regards,
Ramnivas
04-14-2011 12:52 PM
Hi,
Got stumped.
Though the sign looked like single quote (') even in debugging, actually it was ` sign and adding it in special character exclusion list solved the issue.
Thanks & Regards,
Ni3
04-14-2011 12:58 PM
Hi,
did not try it out, but I would assume that " ' " is a special character for ABAP.
Try to mask it, the character to mask another character is " # ", so should do the job
REPLACE ALL OCCURRENCES OF REGEX ' #' ' in corr_string WITH space.
This is just a guess, as already said, I did not try it out.
With kind regards
Uwe Gebhardt
04-14-2011 1:11 PM
Hi Uwe,
The issue has been cleared.
Just for reference of other people I am putting the root cause of the issue.
Different font do have different sign for single quote, for ex: Arial font single quote is (') where courier new single quote is something like (`) that's why it slipped from the excluded list, the same thing for double quote from the two fonts.
Regards,
Ni3
04-14-2011 1:15 PM
>
> did not try it out, but I would assume that " ' " is a special character for ABAP.
" ' " --> Single quote(or apostrophe) is a special character in ABAP.
Try to mask it, the character to mask another character is " # ", so should do the job
No it wont. The [escape character|http://en.wikipedia.org/wiki/Escape_character|Escape Character] for a single quote is single quote itself!
CONSTANT: c_apostrophe TYPE char1 VALUE ''''.
You can also use a string literal to denote a single quote([string literals v/s character literals|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/15889] [original link is broken] [original link is broken] [original link is broken]😉
CONSTANTS c_apostrophe TYPE char1 VALUE `'`.
Cheers,
Suhas