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

regarding select statement

Former Member
0 Likes
1,080

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
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,029

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
Read only

santhosh_patil
Contributor
0 Likes
1,029

Hi,

use like

select -


from ---

where

matnr<b> like</b> p_matnr.

--Patil

Read only

Former Member
0 Likes
1,029

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..

Read only

0 Likes
1,029

Hi Tez,

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

thanks and regards

abaper

Read only

0 Likes
1,029

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.

Read only

Former Member
0 Likes
1,029

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

Read only

Former Member
0 Likes
1,029

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

Read only

0 Likes
1,029

Hi ,

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

rgds

abaper.

Read only

0 Likes
1,029

Hi,

The above select statements are not working.

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

is not working.

K.Kiran.

Read only

0 Likes
1,029

Hi,

use LIKE

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

--Patil

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,030

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.