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

Select material Plant.

Former Member
0 Likes
1,284

Hi All,

SELECT matnr werks

FROM marc INTO TABLE i1_marc where matnr IN s_matnr

AND werks in s_werks AND mmsta = '10'.

On doing this all the plant and material that is been fetched,

I need to determine if table MAST (Material to BOM Link) has an existing record for the same,

can any one help me in this?

Thanks:

Debrup.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
887

Do a JOIN of tables.

5 REPLIES 5
Read only

Former Member
0 Likes
888

Do a JOIN of tables.

Read only

Former Member
0 Likes
887

Hi,

Please convert this Select into a Select based of Inner Join between MARD & MAST.

SELECT marcmatnr marcwerks

INTO TABLE i1_marc

FROM marc inner join MAST

on marc-matnr = MAST-MAtnr and

marc-werks = MAST-werks

where marc~matnr IN s_matnr

AND marcwerks in s_werks AND marcmmsta = '10'.

Read only

Former Member
0 Likes
887

Hi Debrup,

Then what you need to do it first fetch all the plants which are present in the table mast.

And then put a query in the marc table.


SELECT * FROM MAST INTO IT_MAST 
  WHERE WERKS = S_WERKS..
IF NOT MAST[] IS INITIAL.
SELECT matnr werks
FROM marc INTO TABLE i1_marc 
FOR ALL ENTRIES IN 
where matnr IN s_matnr
AND werks = IT_MAST
 AND mmsta = '10'.
ENDIF

Thanks,

Chidanand.

Read only

Former Member
0 Likes
887

Take a SELECT on MAST table as

SELECT matnr werks

FROM mast INTO TABLE i1_mast where matnr IN s_matnr

AND werks in s_werks.

loop at it_marc.

read table it_mast with key matnr = it_marc-matnr and

werks = it_marc-werks.

if sy-subrc = 0.

*record exists in MAST table.

else

*record does not exist in MAST table.

endif.

This will help!!

Read only

Former Member
0 Likes
887

Hi,

Why dont you do a select of MAST directly, you already have the material and the plant in that table. further you can join it with MARC to check mmsta.

As follows :



select * into corresponding fields of table table it_mast
from mast as m
inner join marc on as c
on m~matnr = c~matnr
and m~werks = m~werks
where m~matnr in s_matnr
and    m~werks in s_werks
and    c~mmsta = '10'.

regards,

Advait