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 frame the select query for wildcard search.

Former Member
0 Kudos

Hi Experts,

I have an input field P_USERALIAS.This value could contain the actual value or the wildcard for example : user can enter P_USERALIAS as SAP123 or S or SAPABC123 . I need to generate a dynamic search on table USREFUS depending on what has been entered.Please help.

Useful answers will be rewarded.

Regards,

Shrita Sharma.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

1.

Create a Dummy selection options & hide it on the selection screen using NO Display

fill this with

SIGN = I

OPTION = CP

LOW = WHTEVER

2.

Use LIKE in the where claues

LIKE '%WHATEVER%;

LIKE will cause a performance issue

3 REPLIES 3

Former Member
0 Kudos

you have to use like option and instead of * you have to use %.

like

select < field > from <dbtab> into <itab> where < field1> like 'SAP%123'.

regards

shiba dutta

Former Member
0 Kudos

Hi,

1.

Create a Dummy selection options & hide it on the selection screen using NO Display

fill this with

SIGN = I

OPTION = CP

LOW = WHTEVER

2.

Use LIKE in the where claues

LIKE '%WHATEVER%;

LIKE will cause a performance issue

Former Member
0 Kudos
    • THIS IS A TEST REPORT FOR WILDCARD SEARCH**

TABLES: USREFUS.

PARAMETERS: P_NAME1 TYPE string.

RANGES: R_NAME1 FOR USREFUS-USERALIAS.

DATA: T_usrefus LIKE usrefus OCCURS 0 WITH HEADER LINE.

*replace

if p_name1 cs '*'.

replace all occurrences of '*' in p_name1 with '%'.

SELECT * FROM usrefus

INTO TABLE T_usrefus

WHERE useralias like P_NAME1.

else.

SELECT * FROM usrefus

INTO TABLE T_usrefus

WHERE useralias = p_name1.

endif.

LOOP AT T_usrefus.

WRITE: / T_usrefus-useralias.

ENDLOOP.

**THANKS & REGARDS

SHRITA SHARMA.