Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Single quote sign removal in program

former_member434229
Active Participant
0 Kudos

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

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

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.

8 REPLIES 8

kesavadas_thekkillath
Active Contributor
0 Kudos

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.

0 Kudos

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.

0 Kudos

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.

Former Member
0 Kudos

Hi,

Try the above code suggested by Keshav, it should work.

Regards,

Ramnivas

0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

>

> 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