Skip to Content

Single quote for where clause

Hi ABAPers,

I am building a where clause t_where for selection to table:

CONCATENATE 'FIELD_A LIKE ''' '%' z_a '%'''
INTO z_where-text.

APPEND z_where TO t_where.

SELECT * INTO it_table
FROM z_table
WHERE (t_where).

The issue occurs when z_a contain single quote character '. For example z_a = "Test's data"

The where clause is FIELD_A LIKE '%Test's data%'

It will close the statement in '%Test' and will not recognize s data%'.

It cause run time error.

Any idea how to fix this?

Thanks

Regards

Hadi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on May 07, 2012 at 10:03 AM

    Hello Wadi,

    Instead of using single quotes(') to build the dynamic WHERE clause you can safely use backquotes(`). This should prevent the issue.

    Please refer to the online documentaion: http://help.sap.com/abapdocu_731/en/abenwhere_logexp_dynamic.htm

    BR,

    Suhas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 07, 2012 at 09:49 AM

    Try replace all single quotes ' with two single quotes ''.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.