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: 

problem with LIKE operator in select query

Former Member
0 Kudos
758

Hi,

I want to compare one field using LIKE operator. But i m not able to do that.

DATA: l_doctext type c value ''''.

CONCATENATE l_doctext s_lbktxt-low '%' l_doctext INTO s_lbktxt-low.

SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp

FROM bkpf INTO TABLE g_t_bkpf_labor

FOR ALL ENTRIES IN g_t_bseg_unique

WHERE bukrs = g_t_bseg_unique-bukrs

AND belnr = g_t_bseg_unique-belnr

AND gjahr = g_t_bseg_unique-gjahr

AND blart = p_ldtype

AND bktxt LIKE s_lbktxt-low.

plz help. Am i dng something wrong.

Value in s_lbktxt can be like 'TEA.....'

11 REPLIES 11

Former Member
0 Kudos
257

Hi heena,

You cannot compare a field within the select query as per my knowledge.May be you want to say equal to there .

try this instead of your select query

SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp

FROM bkpf INTO TABLE g_t_bkpf_labor

FOR ALL ENTRIES IN g_t_bseg_unique

WHERE bukrs = g_t_bseg_unique-bukrs

AND belnr = g_t_bseg_unique-belnr

AND gjahr = g_t_bseg_unique-gjahr

AND blart = p_ldtype

AND bktxt = s_lbktxt-low.

Regards,

Abhinay

Former Member
0 Kudos
257

hi ,

we can use the like statement like this..

SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp

FROM bkpf INTO TABLE g_t_bkpf_labor

FOR ALL ENTRIES IN g_t_bseg_unique

WHERE bukrs = g_t_bseg_unique-bukrs

AND belnr = g_t_bseg_unique-belnr

AND gjahr = g_t_bseg_unique-gjahr

AND blart = p_ldtype

AND bktxt LIKE like '%7' or like '*'.

regards,

venkat.

Former Member
0 Kudos
257

do this way

CONCATENATE l_doctext s_lbktxt-low '*' l_doctext INTO s_lbktxt-low.

SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp

FROM bkpf INTO TABLE g_t_bkpf_labor

FOR ALL ENTRIES IN g_t_bseg_unique

WHERE bukrs = g_t_bseg_unique-bukrs

AND belnr = g_t_bseg_unique-belnr

AND gjahr = g_t_bseg_unique-gjahr

AND blart = p_ldtype

AND bktxt LIKE s_lbktxt-low.

Former Member
0 Kudos
257

Hi,

Thanx for the reply. But its my requirement, coz this field wont have directly the value as specified on the selection screen.

It would be incuded part in the value of the field.

Something like identification : like for ex

'TEA-TESTDATA'

0 Kudos
257

Hi Heena,

Hi,

You can build a wildcard ranges and please try something like this.

r_wildcard-sign = 'I'.

r_wildcard-option = 'CP'.

r_wildcard-low = 'B*'.

append r_wildcard.

r_wildcard-sign = 'I'.

r_wildcard-option = 'CP'.

r_wildcard-low = 'B'.

append r_wildcard.

select * from mara

into table gt_mara_b

where mtart = 'YSAB'

and matnr in r_wildcard.

Former Member
0 Kudos
257

hi,

you can also use string operatons...like CS (contain String ), CO ( contains only) ...etc with select query.

try like this....

SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp

FROM bkpf INTO TABLE g_t_bkpf_labor

FOR ALL ENTRIES IN g_t_bseg_unique

WHERE bukrs = g_t_bseg_unique-bukrs

AND belnr = g_t_bseg_unique-belnr

AND gjahr = g_t_bseg_unique-gjahr

AND blart = p_ldtype

AND bktxt CO s_lbktxt-low.

regards,

somesh

  • Reward points if it is helpful

Former Member
0 Kudos
257

data : v_mar(40) type c.

DATA : V_MAR1 TYPE C VALUE 'B'.

DATA : BEGIN OF ITAB OCCURS 0.

INCLUDE STRUCTURE T179T.

DATA : END OF ITAB.

concatenate V_MAR1 '%' INTO V_MAR.

select * from t179t into table itab where vtext like V_MAR.

Former Member
0 Kudos
257

Hi Somesh,

I tries using CO or CS, but its giving me error, of unknown character.

can u plz provide me with some details. I think if ur mentioned idea, can help me.

Former Member
0 Kudos
257

hi ,

check this program..

tables:mara.

data: begin of it_mara occurs 0,

matnr like mara-matnr,

meins like mara-meins ,

mtart like mara-mtart,

end of it_mara.

select-options: s_matnr for mara-matnr.

select matnr

meins

mtart

from mara

into table it_mara

where matnr like '%7'.

sort it_mara by matnr.

loop at it_mara.

write:/ it_mara-matnr,

it_mara-meins,

it_mara-mtart.

endloop.

regards,

venkat.

Former Member
0 Kudos
257

hi,



firstly u declear the field with TYPE. then compare the field.

if helpful give points.

regards,

pankaj

0 Kudos
257

Hi,

Declare field with TYPE in what sense??

Declaring which variable???