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

matnr selection

Former Member
0 Likes
1,961

Hi i need to select matnr from mara passing werks,mmsta and from mvke passing vkorg,vtweg and from marc passing mstae.

werks,mmsta,vkorg,vtweg,mstae are in selection screen.

Kindly help me. results will be rewarded.

5 REPLIES 5
Read only

Former Member
0 Likes
1,052

use parameters or select options for all the fields depending on ur requirement and then use select statement

Read only

Former Member
0 Likes
1,052

Hi,

One way is to put a select query with join on these tables passing the respective fields in where clause of these tables.

But I feel that better idea would be to write select query, then filtering the data and then getting data from other table using for All Entries Clause.

One more option is that you look for some SAP Standard joins. May be there is a join for these tables given by SAP. That would fetch the data faster.

Try these options. You should get the results.

regards,

Lalit Kabra

Read only

Former Member
0 Likes
1,052

Another way of doing this is to form a database view and write a select query if the data record you are pulling comes under the inner join of these tables.

Read only

Former Member
0 Likes
1,052

Hi vincent,

Check this

Select fi

f2

f3

inti itab_marc

from table marc

where werks eq pa_werks

mmsta eq pa_mmsta

vkorg

vtveg

likewise.

if itab_mac[] not initial.

select werks

mmsta

into itab2

from marc

for all entries in itab1

where clause

endif.

then iif itab2[] not initial.

select matnr

into itab3

from mara

for all enrties in itab2

where

clause

endif,

u try this way also, check the syntax and use accordingly

cheers

Mohinder

endif

Read only

Former Member
0 Likes
1,052

Hi.. Need clear info to answer compeltely..

You have mention Fields in Selection-Screen. & which Selection Screen Parameters to retrieve from the Database..

But what are the output fields from the Respective tables, Was not Clear.. or you want the Corresponding MATNR alone.. to be check against these tables mentioned by you..

Here is a Sample Code with the given information....

Selection Screen :

werks,mmsta,vkorg,vtweg,mstae are in selection screen.

Consider all the Selection Screen Field are SELECT-OPTIONS

First Select Query :

1) select matnr from mara passing s_werks, s_mmsta

SELECT matnr FROM MARA INTO TABLE it_mara

WHERE matnr IN s_werks

AND mmsta IN s_mmsta.

Assu: it_mara contains only matnr field.

2) and from mvke passing svkorg, svtweg

3) and from marc passing s_mstae.

Reward Maximum Points for Useful Answers