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: 

Passing partial key in where condtion !

Former Member
0 Kudos
1,130

Hi,

I have come across a requirement where i need to pass partial key in where condition in select query.

For ex :

select * from mara into table lt_mara

                where matnr+16(2) = '10'.

Tried CP(Contains Pattern) aswell.

How to pass partial key in where condition?

Regards

Deva

1 ACCEPTED SOLUTION

Former Member
0 Kudos
612

Try this.  The previous answer would get all entries that ended in '10" regardless of length.  Use 16 underscores instead of "%".

select * from mara into table lt_mara

                where matnr  like  '________________10'.

You could also set up a range table containing an entry with your selection criteria.

select * from mara into table lt_mara

                where matnr  IN r_matnr.

7 REPLIES 7

Former Member
0 Kudos
612

Hi

try to use LIKE in your where condition:

select * from mara into table lt_mara

                where matnr  like  '%10'.

Max

0 Kudos
612

Max, wouldn't matnr  like  '%10' fetch all articles where '10' is present instead of only the ones where            16(2) = '10'?

V.

0 Kudos
612

What Max said is correct.

SELECT SINGLE matnr FROM mara INTO lv_m WHERE matnr like '%10' is the correct since you are selecting articles ending with 10.

0 Kudos
612

what if i want to fetch the matnr which has 10 in the 3rd and 4th character

Ex : MA10TERIAL

0 Kudos
612

MATNR LIKE '__10%'.

V.

0 Kudos
612

Hope the below explanation helps.

Former Member
0 Kudos
613

Try this.  The previous answer would get all entries that ended in '10" regardless of length.  Use 16 underscores instead of "%".

select * from mara into table lt_mara

                where matnr  like  '________________10'.

You could also set up a range table containing an entry with your selection criteria.

select * from mara into table lt_mara

                where matnr  IN r_matnr.