Application Development and Automation 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: 
Read only

Single quote for where clause

former_member647955
Participant
0 Kudos
1,940

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
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
1,032

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
Read only

Former Member
0 Kudos
1,032

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
1,033

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

Read only

0 Kudos
1,032

Hi Suhas,

It's brilliant, it solve the issue.

Thanks