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 for where clause

former_member647955
Participant
0 Kudos
1,447

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

1 ACCEPTED SOLUTION

SuhaSaha
Product and Topic Expert
Product and Topic Expert
539

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

3 REPLIES 3

Former Member
0 Kudos
539

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

SuhaSaha
Product and Topic Expert
Product and Topic Expert
540

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

0 Kudos
539

Hi Suhas,

It's brilliant, it solve the issue.

Thanks