Skip to Content
author's profile photo Former Member
Former Member

How to frame the select query for wildcard search.

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 30, 2007 at 06:16 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2007 at 06:15 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2007 at 06:48 AM
    • 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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.