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

SELECTING DATA FROM TABLE

Former Member
0 Likes
1,376

Hi all,

I have a doubt.

example. select * from mara where matnr = 1234 and werks = ' * ' . where werks i want to keep werks * ie any value how to do it.

I have to use werks field. can i use just %.

Kindly help .

thanks

mahesh

11 REPLIES 11
Read only

Former Member
0 Likes
1,337

Hi,

In that case don't use werks in select query.Just query the table on matnr.

in this case it will fetches the material in different locations.

Thanks,CSR.

Read only

Former Member
0 Likes
1,337

use like this

select * from mara where matnr = '1234'.

this will solve ur problem

Read only

former_member404244
Active Contributor
0 Likes
1,337

Hi,

In mara table there is no werks use marc table and try like this

select * from marc where matnr = '1234' .

Reward if helpful

Regards,

Nagaraj

Read only

former_member386202
Active Contributor
0 Likes
1,337

Hi,

Do like this

select * from mara where matnr = 1234. No need to give the werks in where condition.

Reagrds,

Prashant

Read only

Former Member
0 Likes
1,337

HI THERE,

IF YOU WANT TO SELECT ANY PLANT THEN NO NEED TO USE IT IN THE QUERY. AND BE AWARE THAT YOU DON'T HAVE WERKS FIELD IN MARA TABLE YOU HAVE TO SELECT THAT FROM MARC TABLE.

REGARDS

THARANATHA

Read only

Nawanandana
Active Contributor
0 Likes
1,337

hai

data: m_mara type mara.

SELECT * FROM mara

INTO TABLE m_mara

WHERE matnr = '1234'.

i think u can help

regard

nawa

Read only

0 Likes
1,337

hI ALL,

but my requirement is matnr = 1234 and the werks field for example if it is H101 in the begining if sy-subrc NE 0 i will keep reducing in this manner

h10%

h1&

h%

% untill all characters are searched in the table .My question is finally for any plant is there any option such as * or %.

thanks ,

mahesh

Read only

0 Likes
1,337

Hi,

Try this way


  data : v_like(4) type c.
  concatenate 'H__%' space into v_like.
      select * from marc into table i_marc
         where matnr eq '1234'
           and werks like v_like.

a®

Read only

Former Member
0 Likes
1,337

As Nagaraj stated aboev, WERKS is not a field in the MARA Table. Why Query for WERKS? What are requirements and what are your trying to accomplish with your results?

Read only

Former Member
0 Likes
1,337

in mara table u wont find werks.....

u will find it marc table....

select amatnr bwerks from mara as a join marc as b on bmatnr = amatnr

whwre a~matnr = '1234' and werks = '1%'.

it will retrive the data from mara and marc which the material number is 1234 and werks that start with 1.....

Read only

Former Member
0 Likes
1,337

Hello Mahesh,

Your query, "select * from mara where matnr = 1234 and werks = ' * ' .", won't fetch any data since MARA doesn't have WERKS field.

Instead you need to write like this "<b>select * from MARC where matnr = 1234"</b>" this will fetch all the data for all Plants for which MATNR = 1234

Hope this will be useful

Kindly reward points if it helps.

Regards

Sujay