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

Select where %

Former Member
0 Likes
1,321

Hi All,

Why is the below statment not fetching any data?

SELECT * FROM t012k INTO TABLE gt_t012k WHERE bankn EQ '%15%'.

Data is present in the table T012k having bankn = %15%.

Thanks,

Rakesh.

12 REPLIES 12
Read only

Former Member
0 Likes
1,295

hi rakesh,

instead of <b>where</b> u can use where bankn <b>like</b> here.

regards,

seshu.

Read only

Former Member
0 Likes
1,295

Hi rakesh,

Change code as below.

SELECT * FROM t012k INTO TABLE gt_t012k WHERE bankn <b>LIKE</b> '%15%'.

Regards,

Atish

Read only

former_member186741
Active Contributor
0 Likes
1,295

Do you actually mean that the bankn = '%15%' or is it LIKE it?

If like then you need to code:

SELECT * FROM t012k INTO TABLE gt_t012k WHERE bankn like '%15%'.

Read only

Former Member
0 Likes
1,295

Hi,

You need to write the Select like below

<b>SELECT * FROM t012k INTO TABLE gt_t012k WHERE bankn LIKE '%15%'.</b>

Regards

Sudheer

Read only

0 Likes
1,295

How can i use LIKE % while selecting FOR ALL ENTRIES?

Read only

0 Likes
1,295

Hi Rakesh,

yes you can use it. Just use it as you use EQ NE, etc.

Regards,

Atish

Read only

0 Likes
1,295

LIKE is valid .....show us your full sql and someone will advise you how to edit it.

Read only

0 Likes
1,295

hi rakesh,

try this,

SELECT * FROM t012k INTO TABLE gt_t012k <b>for all entries in <itab></b> WHERE bankn LIKE '%15%'.

regards,

seshu.

Read only

0 Likes
1,295

SELECT * FROM t012k INTO TABLE gt_t012k FOR ALL ENTRIES IN gt_checks2

WHERE bankn LiKE gt_checks2-bankn.

The error am getting is THE addittion FOR ALL ENTRIES cannot be used in the where condition BETWEEN LIKE and IN

Read only

0 Likes
1,295

Hi,

why don't you use operator CS for searching substrings:

SELECT * FROM t012k INTO TABLE gt_t012k

FOR ALL ENTRIES IN gt_checks2

WHERE bankn CS gt_checks2-bankn.

Of course gt_checks2-bankn should not contain the % for substring escaping.

Regards,

Sebastian

Read only

0 Likes
1,295

OK Rakesh I see your problem now. I did not realise that 'like' was not valid if you have a 'for all entries' clause (CP is also not valid).

If all your entries in the table have the % wildcards you can use this code to convert it to a range and then use the adjusted sql:

ranges r_bankn for t012k-bankn.

r_bankn-SIGN = 'I'.

r_bankn-option = 'CP'.

loop at gt_checks2.

R_BANKN-LOW = gt_checks2-BANKN.

REPLACE ALL OCCURRENCES OF '%'

IN R_BANKN-LOW WITH '*'.

append r_bankn.

endloop.

SELECT * FROM t012k INTO TABLE gt_t012k

WHERE bankn IN R_BANKN.

Read only

Former Member
0 Likes
1,295

hi rakesh

please post the way you have defined the internal table.

if you are using the select statement. then try specifying into corresponding fields of table gt_t012k.

try using a key check also with it. like BUKRS or HBKID or HKTID.

and use like also.