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 STATEMENT

Former Member
0 Likes
909

HI,

i have material no , material group , plant in the selection screen

i have retrive the data based on the plant.

pls send me the select statement.

thanks and regards

Nagendra.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
880

tables: Mara,

marc.

types : begin of ty_plant,

matnr type mara-matnr,

matkl type mara-matkl,

werks type marc-werks,

end of ty_plant.

data: it_plant type standard table of ty_plant,

wa_plant type ty_plant.

select-options: s_werks for marc-werks memory id pla.

start-of-selection.

select mara~matnr

mara~matkl

marc~werks

into table it_plant

from mara

inner join marc

on maramatnr = marcmatnr

where werks in s_werks.

if not it_plant[] is initial.

sort it_plant by matnr.

loop at it_plant into wa_plant.

write:/1 wa_plant-matnr,

20 wa_plant-matkl,

30 wa_plant-werks.

endloop.

append wa_plant to it_plant.

clear wa_plant.

endif.

8 REPLIES 8
Read only

Former Member
0 Likes
880

DATA: Begin of itab,
       matnr LIEK mara-matnr,
       matkl LIEK mara-matkl,
       werks LIKE marc-werks,
      END of itab.

SELECT a~matnr a~matkl b~werks 
             FROM mara a inner join marc as b
             ON a~matnr = b~matnr
             INTO TABLE itab
             WHERE b~werks IN s_werks.

Hope this will solve.

Reward if this helps.

Read only

Former Member
0 Likes
880

data: begin of itab occurs 0,

matnr LIKe mara-matnr,

matkl LIKe mara-matkl,

werks LIKE marc-werks,

end of itab .

select mara~matnr

mara~matkl

marc~werks

from mara inner join marc

on maramatnr = marcmatnr

into table itab

where mara~matnr in s_matnr

and mara~matkl in s_matkl.

Read only

Former Member
0 Likes
880

hi,

tables : mara,marc.

DATA: Begin of itab,

matnr type mara-matnr,

matkl type mara-matkl,

werks typr marc-werks,

END of itab.

select-options:s_werks for marc-werks.

SELECT amatnr amatkl b~werks

FROM mara a inner join marc as b

ON amatnr = bmatnr

INTO TABLE itab

WHERE b~werks IN s_werks.

loop at itab.

write 😕 itab-matnr,

itab-matkl,

itab-werks.

endloop.

if helpful award points.

sri

Read only

Former Member
0 Likes
880

Hi nagendra,

Select PLANT form Dbtable where plant eq P_plant(selection screen parametr for theplant).

ifsy-subrc eq 0.

select FIELD1 FIELD2 from DBTable where .....

else.

Message E1000(ZAKHA) with Plant doesnt availble..

Regards,

KIShore.

Read only

Former Member
0 Likes
881

tables: Mara,

marc.

types : begin of ty_plant,

matnr type mara-matnr,

matkl type mara-matkl,

werks type marc-werks,

end of ty_plant.

data: it_plant type standard table of ty_plant,

wa_plant type ty_plant.

select-options: s_werks for marc-werks memory id pla.

start-of-selection.

select mara~matnr

mara~matkl

marc~werks

into table it_plant

from mara

inner join marc

on maramatnr = marcmatnr

where werks in s_werks.

if not it_plant[] is initial.

sort it_plant by matnr.

loop at it_plant into wa_plant.

write:/1 wa_plant-matnr,

20 wa_plant-matkl,

30 wa_plant-werks.

endloop.

append wa_plant to it_plant.

clear wa_plant.

endif.

Read only

Former Member
0 Likes
880

Hi,

Use any of the query suggested above but the data should be selected first from MARC table as MARC has index on Material and Plant combination. Hence the query will definately run faster as any way you have plants with you.

select - - - - - -

FROM MARC inner join MARA

where werks in s_werks." -


primary index

hope this helps.

Regards,

Shahu

regards,

Shahu

Read only

Former Member
0 Likes
880

nagendra,

DATA: Begin of i_mara,

matnr LIEK mara-matnr,

matkl LIEK mara-matkl,

werks LIKE marc-werks,

END of itab.

SELECT amatnr amatkl b~werks

FROM mara a inner join marc as b

ON amatnr = bmatnr

INTO TABLE i_mara

WHERE b~werks IN s_werks.

Pls. reward for all useful ans.

Read only

Former Member
0 Likes
880

Hi Nag,

TYPES: Begin of ts_itab,

matnr LIEK mara-matnr,

matkl LIEK mara-matkl,

werks LIKE marc-werks,

END of ts_itab,

tt_itab type standard table of ts_itab.

DATA: WA TYPE TS_ITAB,

ITAB TYPE TT_ITAB.

SELECT amatnr amatkl b~werks

INTO TABLE itab

FROM mara AS a inner join marc AS b

ON amatnr = bmatnr

WHERE b~werks IN s_werks

LOOP AT ITAB INTO WA.

WRITE:/ WA-MATNR,

WA-MATKL,

WA-WERKS,

ENDLOOP.

Pls Reward if Helpful...

Mahe