2015 Jul 16 6:12 PM
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
2015 Jul 16 6:23 PM
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.
2015 Jul 16 6:16 PM
Hi
try to use LIKE in your where condition:
select * from mara into table lt_mara
where matnr like '%10'.
Max
2015 Jul 16 6:23 PM
Max, wouldn't matnr like '%10' fetch all articles where '10' is present instead of only the ones where 16(2) = '10'?
V.
2015 Jul 16 6:32 PM
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.
2015 Jul 16 6:40 PM
what if i want to fetch the matnr which has 10 in the 3rd and 4th character
Ex : MA10TERIAL
2015 Jul 16 6:59 PM
2015 Jul 16 7:02 PM
2015 Jul 16 6:23 PM
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.