Application Development 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: 

regarding select statement

Former Member
0 Kudos

Hi,

i am using material code ( declared as parameter statement ) in where clause of select statemant . i want to run the select for input like DC* in parameter so that all materials starting from DC are included in the select.

thanks and regards

abaper.

1 ACCEPTED SOLUTION

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you are using select-options, you can achieve the result without extra effect.

If you want to use only parameter, you need to use ranges in your logic and equate option = 'CP'.Here is the code.It is working fine.Kindly reward points by clicking the star on the left of reply,if it helps.

parameters p_matnr type matnr.

tables mara.

data itab type standard table of mara.

data wa type mara.

ranges r_matnr for mara-matnr.

r_matnr-low = p_matnr.

r_matnr-sign = 'I'.

r_matnr-option = '<b>CP</b>'.

append r_matnr.

select * from mara into table itab where matnr <b>in r_matnr</b>.

loop at itab into wa.

write wa-matnr.

endloop.

10 REPLIES 10

santhosh_patil
Contributor
0 Kudos

Hi,

use like

select -


from ---

where

matnr<b> like</b> p_matnr.

--Patil

Former Member
0 Kudos

Hi King,

This is dynamic selection and * is not used in this clause. You can use % instead of * to achieve at the solution.

This sholud solve your query.

Reward Points if useful.

Thanks,

Tej..

0 Kudos

Hi Tez,

can you write the full select statement. where to write %

thanks and regards

abaper

0 Kudos

HI,

select * from mara into i_mara where matnr = 'dc%'.

this select statement will select all the record which is having material number starts with "dc"

rgds,

bharat.

Former Member
0 Kudos

select matnr from mara into table itab where matnr like P_MATNR.

Former Member
0 Kudos

Hi again King,

Use this way.

Select field1 field 2

from table

into int_table

where sel_field = 'DC%'.

Note: <b>Always remember that the code within single cotes should be in CAPS</b>.

This should solve your query.

Reward Points if useful.

Thanks,

Tej..

Message was edited by:

Shree Tejus

0 Kudos

Hi ,

thanks for your reply , but i dont want to hard code it .

rgds

abaper.

0 Kudos

Hi,

The above select statements are not working.

select maktx from makt into table imakt where makt = 'T%'.

is not working.

K.Kiran.

0 Kudos

Hi,

use LIKE

select maktx from makt into table imakt where makt<b> like</b> 'T%'.

--Patil

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you are using select-options, you can achieve the result without extra effect.

If you want to use only parameter, you need to use ranges in your logic and equate option = 'CP'.Here is the code.It is working fine.Kindly reward points by clicking the star on the left of reply,if it helps.

parameters p_matnr type matnr.

tables mara.

data itab type standard table of mara.

data wa type mara.

ranges r_matnr for mara-matnr.

r_matnr-low = p_matnr.

r_matnr-sign = 'I'.

r_matnr-option = '<b>CP</b>'.

append r_matnr.

select * from mara into table itab where matnr <b>in r_matnr</b>.

loop at itab into wa.

write wa-matnr.

endloop.