cancel
Showing results for 
Search instead for 
Did you mean: 

How to search char field data using wild card option with no casesenstive?

Former Member
0 Kudos

How to search char field data using wild card option with no casesenstive?

ex - if i give in search - a*

it should able to pick up all the records ..

ABAP

Abap

abap

abaP

i tried like this

ranges: r_name for kna1-name1.

r_name-sign = 'I'.

r_name-option = 'CP'.

if name is initial.

r_name-low = '*'.

else.

r_name-low = name.

endif.

append r_name.

but this is working fine for wildcard.. but how to extend this for with out case sensitive search?

thanks.

Murali.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Murali..

Just to inform you that the wildcard you use on the selection screen is different from what you code..

We use astrisk sign * in the screen like A* to find all words starting with 'A'.

But when we code this in a SELECT query, we take '%' sign instead of *.

WHERE name LIKE 'A%'

Thanks and Best Regards,

Vikas Bittera.

**Points for useful answers**

Former Member
0 Kudos

Hi Murali,

You can check this thread

Sri.

Former Member
0 Kudos

If you want KNA1-NAME1, use KNA1-MCOD1 instead. It's NAME1 translated to uppercase (and shortened to 25 from 35 characters).

Rob

Former Member
0 Kudos

Hi Rob

thanks for ur answer, actually i have 8 fields in 3 tables like this to search. I found all the allternate search fields for this.

Thanks for ur hint and time.

Murali.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

And if there wasn't an alternative field, you could always just translate the field to upper case and then do the check.

translate field to upper case.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi..

well if i trasnlate to upper case (in data base if it is having lower case or some thing like this (Book) first letter upper and rest all lower) then its not picking the record.

But still need to know if i dont have allternate field how to solve this?

CS is not working-i got shortdump saying that

The OPTION column should contain only one of the

-


following values:

"EQ LE GE CP BT NE LT GT NP NB"

The value "CS" is not allowed here.

-


thanks

Murali.

Former Member
0 Kudos

You can do it using native SQL, but it's something to avoid.

Rob

Former Member
0 Kudos

Like this:


report ztest no standard page heading.

tables lfa1.

data: name like lfa1-name1 value 'DELL'.

EXEC SQL.
  SELECT *
  INTO :LFA1
  FROM  LFA1
  WHERE UPPER(NAME1)  =  :NAME
ENDEXEC.

Rob

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Take the following example. Here we are using the name field from KNA1. I'm looking for anything that has RICH in the name reqardless of case. If I don't translate this, nothing will show. If I check the checkbox for translating, then I will get values.



report zrich_0002.

data: ikna1 type table of kna1 with header line.

select-options: s_name1 for ikna1-name1 no intervals .

parameters: p_trlt as checkbox.   " Should it be translated?

initialization.
  s_name1-sign = 'I'.
  s_name1-option = 'CP'.
  s_name1-low = '*Rich*'.
  append s_name1.

start-of-selection.

  if p_trlt = 'X'.
    loop at s_name1.
      translate s_name1-low to upper case.
      translate s_name1-high to upper case.
      modify s_name1.
    endloop.
  endif.


  select * into corresponding fields of table ikna1
            from kna1
                  where name1 in s_name1.


  loop at ikna1.
    write:/ ikna1-name1.

  endloop.

Regards,

Rich HEilman

Former Member
0 Kudos

Well, I like that a lot better than native SQL.

Rob

Former Member
0 Kudos

thanks for ur answer.

but actually this requirement is for BAPI, i need to implement this in BAPI, and user just use search from the portal using any value in search fields like (S* or s*).

thanks

Murali

Former Member
0 Kudos

Hi Rich HEilman,

user dont have option to select to translate to lower case or upper case.

what ever user enters(like s * or S* it needs to pick up all the records with s and S in table), it needs to take care in BAPI code to get the corresponding records.

thanks

Murali.

Former Member
0 Kudos

Hi,

We are also facing the similar kind of issue. Can you please tell us how you search the wild card option with no casesenstive

Regards

Karthik T

Former Member
0 Kudos

Hi Murali,

Instead of using 'CP' in your ranges use 'CS' which is not case sensitive.

Former Member
0 Kudos

Append one more record to your range with other case.

Hope this helps.Use append inside the if and else condition itself.

r_name-sign = 'I'.

r_name-option = 'CP'.

if name is initial.

r_name-low = 'A*'.

append r_name.

r_name-low = 'a*'.

append r_name.

else.

r_name-low = name.

append r_name

endif.

Hope this helps.