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: 

How to handle single quote between two single quotes in ABAP?

Former Member
0 Kudos

Dear SAP Gurus

I have a question regarding handling a string data.

Say I have a string ABCD'\&%$!!ABC'AAA123. Please notice that there are single quotes in my string.

I am writing a parser code in ABAP and getting into problem with if statement to check if the character read is a single quote.

When I type the following with a singleQuote between 2 singleQuoes as below, it gives error.

If CHAR = '''.

ENDIF.

How do I handle that? I searched for escape sequence and couldn't get any useful info.

Any feedback will be highly appreciated.

Thanks

Ram

1 ACCEPTED SOLUTION

ThomasZloch
Active Contributor

Two single quotes represent one single quote for such purposes, means that you need four in a row in your example.

Thomas

5 REPLIES 5

ThomasZloch
Active Contributor

Two single quotes represent one single quote for such purposes, means that you need four in a row in your example.

Thomas

0 Kudos

Thanks for all the help. I appreciate it a lot. Used the first suggestion of having 4 quotes and it worked. Good to know other alternatives also. Thanks.

Former Member
0 Kudos

Before parsing, you can REPLACE ALL OCCURRENCES OF '''' IN your_variable WITH some other character or group of characters that you don't expect to find. Then parse based on the new character(s).

Rob

MarcinPciak
Active Contributor
0 Kudos

Or just use string literals


if char = `'`.   "note that ` is the "backquotation" mark not a regular quotation mark ' 

Regards

Marcin

piyush-chaudhary
Discoverer
0 Kudos

I am getting the same issue for below i18nn text:

dlDescription=When the checkbox for downloading data with tooltips is checked, you'll receive a download link via email

But now adding the double quotes for the single quote is not working as expected.