Application Development and Automation 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: 
Read only

wild card in select statement

Former Member
0 Likes
816

hi,

I want to select following feilds from KNA1 KUNNR

NAME1

NAME2

LAND1

ORT01

PSTLZ

REGIO

STRAS

TELF1

ADRNR

ERNAM

ERDAT

based on the following condition below:

Wildcard on customer name:

a. Starts with

b. Contains

Please send me a sample code of how to select the customer name based on the above conditions

rewards guaranteed.

neha

hi,

I want to select following feilds from KNA1 KUNNR

NAME1

NAME2

LAND1

ORT01

PSTLZ

REGIO

STRAS

TELF1

ADRNR

ERNAM

ERDAT

based on the following condition below:

Wildcard on customer name:

a. Starts with

b. Contains

Please send me a sample code of how to select the customer name based on the above conditions

rewards guaranteed.

neha

5 REPLIES 5
Read only

Former Member
0 Likes
772

Hi..

select

KUNNR

NAME1

NAME2

LAND1

ORT01

PSTLZ

REGIO

STRAS

TELF1

ADRNR

ERNAM

ERDAT

from KNA1

INTO TABLE ITAB

<b>WHERE NAME1 LIKE 'SAI%' . "<-- Starts with SAI

-


WHERE NAME1 LIKE '%SAI%' . "<--Contains SAI</b>

Here SAI is case sensitive .. if u give in Capital letters then it will search for capital letters onli.

reward if it helps u..

sai ramesh

Read only

Former Member
0 Likes
772

HI

Select

NAME1

NAME2

LAND1

ORT01

PSTLZ

REGIO

STRAS

TELF1

ADRNR

ERNAM

ERDAT

from KNA1

INTO TABLE ITAB

WHERE NAME1 LIKE 'A%' .

Hope this helps

Regds

Seema

Read only

Former Member
0 Likes
772

Hi..

<b>1.% for a sequence of any characters (including spaces).

2._ for a single character.</b>

select

KUNNR

NAME1

NAME2

LAND1

ORT01

PSTLZ

REGIO

STRAS

TELF1

ADRNR

ERNAM

ERDAT

from KNA1

into itab

where NAME1 like 'R%' . "or

<u>for second one,</u>

lets say ur string is 'ram'.

<b>concatenate '%' 'ram' '%' into w_string.</b>

<b>select ....

from kna1

into itab

where name1 like w_string.</b>

Read only

Former Member
0 Likes
772

Hai,

Here is the sample code:

SELECT

KUNNR

NAME1

NAME2

LAND1

ORT01

PSTLZ

REGIO

STRAS

TELF1

ADRNR

ERNAM

ERDAT

FROM KNA1

WHERE CUSTOMER NO LIKE 'ABC%XYZ%'.

It means:

Customer no Starts with

ABC and Contains the string XYZ

% wildcard means zero or nore any characters.

Possible Customer numbers are:

ABCppppXYZqqq

ABCXYZqqq

ABCXYZ

Hope you got idea.

<b>Reward points if it helps you.</b>

Regds,

Rama chary.Pammi

Read only

Former Member
0 Likes
772

Hi neha,

Now we shall look at another way.

All the above ways will work.

ranges: s_name1 for kna1-name1.

<b>* For starts with</b>

s_NAME1-sign = 'I'.

s_name1-option = 'CP'.

concatenate s_name1-low '*' into s_name1-low.

append s_name1.

select * from kane1 into table

where name1 in s_name1.

<b>* For Contains</b>

s_NAME1-sign = 'I'.

s_name1-option = 'CP'.

concatenate '" s_name1-low '' into s_name1-low.

append s_name1.

select * from kane1 into table

where name1 in s_name1.

Regards,

Ravi