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.
Showing results for 
Search instead for 
Did you mean: 

ABAP Query

Former Member
0 Kudos


We want a query to be generated using 5 tables.

MARA,MAKT,MARD,MBEW & MARC. In the output, we are getting the redundant data. ie. Material Number is repeating more than once. For Eg, if 100021 is the mat no. its appearing 3 times in the output list.

How to filter the selection.

Is there any SQL Query option there, for manual selection, how to do it.

Thanks in Advance.




Active Contributor
0 Kudos


Just use distinct in your query after select.

select distinct fieldnames into targetfields from databasetable where condition.

see the F1 help for 'Distinct'.

If you are want to restrict it after populating it in internal table , you can use


Former Member
0 Kudos

Hi Syed,

The way I look at it, the problem is MBEW and MAKT.

<b>MAKT Scenario 1</b>

Add MAKT-SPRAS to the selection screen and make it mandatory. If you have descriptions in multiple languages defined this will get rid of duplicate records being generated due to multiple descriptions.

<b>MBEW Scenario 1</b>

Add and additional link from MBEW-BWKEY to MARC-WERKS in the join definition if the Valuation Area (MBEW-BWKEY) is the same as the Plant (MARC-WERKS).

<b>MBEW Scenario 2</b>

If that is not the case, add 2 more tables to yout join T001K and T001W

The Links will be established automatically, now link MARC-MATNR to MBEW-MATNR and T001W-WERKS to MARC-WERKS and delete any other links to MARC from T001w.

<b>End Result</b>

This should eliminate your duplicates and give you more accurate results, as compared to adding code in the query as you may be deleting the wrong entry or not getting accurate data to begin with.