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

Duplicate entries are displaying for MBV_MBEW only in AMDP class SQL query

Waruna
Participant
0 Kudos

Hi Experts,

Duplicate entries displaying in the following query result in AMDP class. But when I checked data with the SE16N no duplicate entries were found. I have used the proxy object MBV_MBEW. I need to get Material Valuation. data duplicating with 0 entry with salk3, lbkum.

    it_mbv_mbew = select distinct matnr, bwkey, salk3, lbkum
                    from MBV_MBEW;
5 REPLIES 5

xiaosanyu
Participant

Add a where condition 'where mandt = ....'

Sandra_Rossi
Active Contributor
0 Kudos

DISTINCT can't return duplicate values.

It's probably what comes next which make you SEE (i.e. apparently) that there are duplicates.

Please clarify.

raymond_giuseppi
Active Contributor

You don't provide the full key, so there are multiple records if you use split valuation.

You could try (The 3 first fields will remove duplicates and the where clause remove the total records in case of split valuation)

    it_mbv_mbew = select matnr, bwkey, bwtar, salk3, lbkum
                    from MBV_MBEW where bwtty = space OR bwtar <> space ;

or use some aggregation. What was the original requirement?

Waruna
Participant
0 Kudos

Thank you all.

Problem solved by adding where condition mandt = SESSION_CONTEXT('CLIENT'). Thank you again xiaosanyu

    it_mbv_mbew = select distinct matnr, bwkey, salk3, lbkum
                    from MBV_MBEW
                    where mandt = SESSION_CONTEXT('CLIENT');

Waruna
Participant
0 Kudos

Problem solved by adding where condition mandt = SESSION_CONTEXT('CLIENT'). Thank you xiaosanyu