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: 

How to search records in a standard table with * ?

Former Member
0 Kudos

Hi everyone,

Can anyone tell me how to search records in a standard table with * ?

That is, in screen if user type * abc * for searching the records in which the field MC_STEXT contains 'abc'. What the code should be? How to complete the code below?

SELECT SINGLE objid FROM p1000 INTO p1000-objid,

WHERE MC_STEXT = ? .

Thanks!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

There are several way to do that, probably just as some guys wrote the easier way is to use LIKE in WHERE condition and the sign % instead of *:

V_STRING = '%ABC%'.

SELECT SINGLE objid FROM p1000 INTO p1000-objid,

WHERE MC_STEXT LIKE V_STRING.

U can also use a range (just like select-options):

RANGES: R_MC FOR P1000-MC_STEXT.

R_MC-LOW = 'ABC'.

R_MC(3) = 'ICP'.

APPEND R_MC.

SELECT SINGLE objid FROM p1000 INTO p1000-objid,

WHERE MC_STEXT IN R_MC.

Max

8 REPLIES 8

JozsefSzikszai
Active Contributor
0 Kudos

hi,

WHERE msc_text LIKE p_...

(p_... will be the parameter from the selection screen)

hope this helps

ec

former_member181995
Active Contributor
0 Kudos

SELECT SINGLE objid FROM p1000 INTO p1000-objid,

WHERE MC_STEXT like '%abc%' .

Former Member
0 Kudos

Hi,

Please check the below code.

When ever ur searching using select statement use %.

p_search = '%abc%'.
SELECT SINGLE objid FROM p1000 INTO p1000-objid,
WHERE MC_STEXT = p_search.

Regards,

0 Kudos

>

> Hi,

>

> Please check the below code.

> When ever ur searching using select statement use %.

>

p_search = '%abc%'.
> SELECT SINGLE objid FROM p1000 INTO p1000-objid,
> WHERE MC_STEXT = p_search.

>

> Regards,

should be LIKE

0 Kudos

Thanks Chandra,

If I hava an importation field like OBJID instead of 'abc', then how to write the code?

p_search = ?

Thanks!

0 Kudos

Let us say ur important field is 'input1'.

CONCATENATE: '%' input1'%' INTO p_search.
SELECT SINGLE objid FROM p1000 INTO p1000-objid,
WHERE MC_STEXT LIKE p_search.

Regards,

Former Member
0 Kudos

Hi

There are several way to do that, probably just as some guys wrote the easier way is to use LIKE in WHERE condition and the sign % instead of *:

V_STRING = '%ABC%'.

SELECT SINGLE objid FROM p1000 INTO p1000-objid,

WHERE MC_STEXT LIKE V_STRING.

U can also use a range (just like select-options):

RANGES: R_MC FOR P1000-MC_STEXT.

R_MC-LOW = 'ABC'.

R_MC(3) = 'ICP'.

APPEND R_MC.

SELECT SINGLE objid FROM p1000 INTO p1000-objid,

WHERE MC_STEXT IN R_MC.

Max

Subhankar
Active Contributor
0 Kudos

Hi...

If the input field is as parameter, make a select query as this.

select * form mara into table I_MARA

where matnr like p_field.

if it select option

select * form mara into table I_MARA

where matnr in s_field.