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: 

Qurey in select statment

Former Member
0 Kudos

Hi ,

How can i use select qurey using where clause with 9*....

Example :

SELECT matnr FROM mara into it_mara

WHERE matnr = p_material number.

ie , This is parameter in selection screen -here defaultly giving as below

p_material number = '9*'.

i have used the above select but it failed .can any one help me sort out this ?

Regards

Maha

16 REPLIES 16

Former Member
0 Kudos

SELECT matnr FROM mara into it_mara

WHERE matnr like '9%'

Kiran

Edited by: kiran vempati on Mar 6, 2009 1:14 PM

I355602
Advisor
Advisor
0 Kudos

Hi,

Use it this way:-


SELECT matnr FROM mara
into table it_mara "internal table
WHERE matnr like '9*'.

Regards,

Tarun

Former Member
0 Kudos

Hi all,

still it gets fail .Not able to fix .

Maha

0 Kudos

Hi,

Are you getting any error or no data is being displayed...??

Also make sure the data exists for mantr as 9....

Hope this helps you.

Regards,

Tarun

Former Member
0 Kudos

Tarun,

No error , sy-subrc = 4 and the data's are in DB.Not sure why .

Regards,

MAHA

0 Kudos

Hi,

If there is no data in database table, then the query wont fetch the data and will give sy-subrc as 4.

So make sure that there is some data in table for matnr = 9*...

Regards,

Tarun

Former Member
0 Kudos

Hi ,

9* values are there in data base table . i had confirmed .

Regards,

Maha

keerthy_k
Active Participant
0 Kudos

Hi

it wont work with 9*...u need to give it as 9% and 'LIKE' in the where clause as

where matnr like '9%'.

I have tried this and its working.

Keerthi

0 Kudos

Hi,

Try this its working, i have checked:-


DATA : BEGIN OF itab OCCURS 0,
       matnr TYPE mara-matnr,
       END OF itab.

DATA : v_matnr TYPE mara-matnr.

v_matnr = '9%'.

SELECT matnr FROM mara INTO TABLE itab WHERE matnr LIKE v_matnr.

WRITE : sy-subrc.

LOOP AT itab.
  WRITE: / itab-matnr.
ENDLOOP.

Hope this solves your issue.

Regards,

Tarun

Former Member
0 Kudos

Hi,

You can use like statement with you select query,

i.e like '9*' after your select query.

Regrds

Mansi

Former Member
0 Kudos

hi,

you have written the write query.just change where clause

insterad of wiritng p_matnr = P-matnr material number.

WRITE

WHERE matnr like '9*'.

Hope it will solve your problem

Thanks

Arun

Former Member
0 Kudos

Hi,

Try like this...



Use percentage symbol

SELECT matnr FROM mara into table it_mara 
WHERE matnr like '9%'.

Hope its helps

Former Member
0 Kudos

SELECT matnr FROM mara into it_mara

WHERE matnr LIKE p_material number*.

keerthy_k
Active Participant
0 Kudos

Hi,

Try as below:

select * from sflight into table itab

where carrid like 'A%'.

loop at itab into wa.

write:/ wa-carrid.

endloop.

u cant use *...just use % instead of that and in where condition use LIKE.

Keerthi

Former Member
0 Kudos

Yah where matnr like '9%'. is working with me also

Just check other things in your select qurey.

Former Member
0 Kudos

try this way it will work...

select - options :p_material number for mara-matnr with no-intervals no-extensions.

SELECT matnr FROM mara into it_mara

WHERE matnr in p_material number.

Regards,

Prabhudas