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

Wild card Characters

Hi

I have a requirement in which I have document header text(BKPF-BKTXT) on selection screen.The user can enter wildcard characters also in the search.For e.g if user enters (test) then it should retrieve all the possible records starting with test.The records can be test123,TEST123,Test123,TEst123,TESt123,tEst123..etc.for eg if user enters Test then also it should return all the possible header texts starting with test.

Please advise.

Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:47 AM

    Hi,

    From the selection screen,fetch 'TEST'.Put it in some variable.Replace TEST by TEST%.In the select query write.:

    var = 'TEST%'.

    select f1 from <table>

    where f1 like var.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 17, 2008 at 10:56 AM

    Hi,

    {*} needs to be replaced with %.

    ? needs to be replaced with _ while fetching the values from table.

    If you want to use ? or {} as it is then you have use some escape character. In this case, {} needs to be replaced with #%.

    ? needs to be replaced with #_ . Here escape character is #

    select * from <table> into table <internal table> where <column> like mod_search_pattern

    escape '#'.

    Reward points if useful.

    Regards,

    Siva.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 17, 2008 at 11:05 AM

    If you are using selection screen as you mentioned in your question, you can simply use 'Select-options' to get user input.

    You can use select-options with addition of "NO-EXTENSION" and "NO INTERVALS". This way user will see a single field just like a parameter but in fact it is a select-option so you can simply use it in you select statement without any conversion. e.g.

    select * from bkpf where bktxt in s_bktxt.

    The pattern matching logic is handeled by select-option itself.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 11:41 AM

    Hi,

    Refer the example code :

    data : str(20) type c,
           num type n.
    
    str = 'SAP'.
    num = strlen( str ).
    str+num(1) = '%'.
    
    write : str.
    
    "Now you can use str in select statement using LIKE operator.
    

    Thanks,

    Sriram Ponna.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 11:46 AM

    HI,

    You need not modify the select option, if you enter * in the selct option, then option will have "CP", so the selct statement fetches all the data starting with test* ,

    Thanks,

    Keerthi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 11:48 AM

    HI,

    You can use LIKE in the SELECT statement when you are using wild characters in WHERE class. Check the belwo code...

    Concatenate p_bktxt '%' into v_bktxt.

    SELECT .....From BKPF INTO TABLE i_bkpf WHERE BKTXT LIKE v_bktxt.

    Rgds,

    Bujji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 01:23 PM

    But I can't see how any of the solutions posted so far can cope with the mixture of upper and lower case ?

    I had a requirement similar to this recently, what I did was to have a select option on BKTXT, loop through it converting to upper case, not use it at all in the WHERE clause of the SELECT, go through the iinternal table of data returned copying BKTXT and converting it to upper case in a new column, and then looping at the itab where the upper case BKTXT is in the select option. Not exactly elegant or efficient but can't see any other way around it.

    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.