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

Problem in using LIKE addition in SELECT statement

Former Member
0 Likes
550

HI Experts,

Have a small query for you :

While selecting from Database I want to fetch all records which have the field name like "HR_".

I wrote following select query :

l_tsobj TYPE tst01-dname VALUE 'HR_%',

SELECT * INTO TABLE ltst01 FROM tst01 WHERE dname LIKE l_tsobj.

During debugging it shows me all records like HR_ & all records like HRL.

Not sure why it is fetching records like HRL from database .

In table tst01 total number of records having HR_ = 1231

but the above query select in total 1231 + 2000( records having HRL ..... pattern also ).

I want to restrict data selection at database level only & not at internal table level . Please suggest.

Thanks,

Abhinav.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
514

Hi,

you have to use ESCAPE statement.


DATA:      
  l_tsobj TYPE tst01-dname VALUE 'HR/_%'.

SELECT * 
  INTO TABLE ltst01 
  FROM tst01 
  WHERE dname LIKE l_tsobj ESCAPE '/'.

Regards Marcel

4 REPLIES 4
Read only

Former Member
0 Likes
514

try this..

data : l_tsobj TYPE STRING VALUE 'HR_%',

Read only

0 Likes
514

Doesn't help already tried that

Read only

Former Member
0 Likes
515

Hi,

you have to use ESCAPE statement.


DATA:      
  l_tsobj TYPE tst01-dname VALUE 'HR/_%'.

SELECT * 
  INTO TABLE ltst01 
  FROM tst01 
  WHERE dname LIKE l_tsobj ESCAPE '/'.

Regards Marcel

Read only

0 Likes
514

thanks Marcel it resolved my problem...