Skip to main content

Notifications

Supply chain | Supply Chain Management, Commerce
Suggested answer

loop returns duplicates rows when batch is repeated in invent trans table

(0) ShareShare
ReportReport
Posted on by
This is my while
    while select packingSlipJour
    where packingSlipJour.RecId == packingSlipJourId.RecId
    join packingSlipTrans
    where packingSlipJour.PackingSlipId == packingSlipTrans.PackingSlipId
    join transOrigin
    where packingSlipTrans.InventTransId == transOrigin.InventTransId
    join inventTrans
    where inventTrans.InventTransOrigin == transOrigin.RecId
    join inventDim
    where inventTrans.InventDimId == inventDim.InventDimId
    join inventBatch
    where inventDim.InventBatchId == inventBatch.InventBatchId
        && inventDim.DataAreaId == inventBatch.DataAreaId
    join inventTable
    where inventTable.ItemId == transOrigin.ItemId
    join productTranslation
    where productTranslation.Product == inventTable.Product
    join inventLocation
    where inventLocation.InventLocationId == inventDim.InventLocationId  and this my output I want distinct rows.
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,253 Most Valuable Professional on at
    loop returns duplicates rows when batch is repeated in invent trans table
    You need to analyze which table returns more rows when you expect just one. You can, for example, look at RecId of each table in the result set. You can also remove data sources one by one to see which one is to blame.
     
    I immediately see one problem. You're joining with EcoResProductTranslation table, where you may have multiple values for the product. If you want your query to return just one, add a filter for the language.

    By the way, throw away the condition inventDim.DataAreaId == inventBatch.DataAreaId. It's applied automatically (that's why you didn't have to add it for all the other table either).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,253 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans