Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Help with POP query for smartlist builder

(0) ShareShare
ReportReport
Posted on by 2,395

Hi all, i'm trying to make a POP smartlist with the following information:

PO Number

PO line number

Item ID

Item description

Vendor ID

Qty ordered

Qty delivered

Required date

Promised date

Released date

Vendor name

Buyer ID

Actual cost

UofM

Invoiced qty (if any)

Comment ID

What I have so far is:

SELECT     TOP (100) PERCENT POP.PONUMBER, POP.ORD, POP.ITEMNMBR, QTYRCP.POPRCTNM, QTYRCP.QTYSHPPD, POP.ITEMDESC, POP.VENDORID, POP.LineNumber, POP.REQDATE,

                     POP.PRMSHPDTE, POP.PRMDATE, POP.QTYORDER, dbo.IV00101.CURRCOST, POP.UOFM, QTYRCP.QTYINVCD, dbo.POP10100.USER2ENT, dbo.PM00200.VENDNAME, POP.POLNESTA AS estado,

                     POP.Released_Date, dbo.POP10100.DOCDATE

FROM         dbo.POP10500 AS QTYRCP INNER JOIN

                     dbo.POP10100 ON QTYRCP.PONUMBER = dbo.POP10100.PONUMBER INNER JOIN

                     dbo.POP10110 AS POP INNER JOIN

                     dbo.PM00200 ON POP.VENDORID = dbo.PM00200.VENDORID LEFT OUTER JOIN

                     dbo.IV00101 ON POP.ITEMNMBR = dbo.IV00101.ITEMNMBR ON QTYRCP.POLNENUM = POP.ORD AND QTYRCP.ITEMNMBR = POP.ITEMNMBR AND ISNULL(QTYRCP.QTYSHPPD, 0)

                     < POP.QTYORDER

WHERE     (POP.POLNESTA IN (1, 2, 3, 4))

ORDER BY POP.PONUMBER, POP.ITEMNMBR

But I keep getting duplicated records, hope someone can help me with this.

*This post is locked for comments

  • RE: Help with POP query for smartlist builder

    Thanks a lot  thetrev68 I think this nailed it!

    Best regards.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Help with POP query for smartlist builder

    I had difficulty following your joins.  Try this...

    SELECT RTRIM(A.PONUMBER) [PO Number]

    , B.LineNumber [PO Line No.]

    , RTRIM(B.ITEMNMBR) [Item Number]

    , RTRIM(B.ITEMDESC) [Item Description]

    , B.VENDORID [Vendor ID]

    , B.QTYORDER -  B.QTYCANCE [Qty Ordered]

    , ISNULL(C.QTYSHPPD,0) [Qty Received]

    , B.REQDATE [Required Date]

    , B.PRMSHPDTE [Promised Date]

    , A.DOCDATE [Released Date]

    , RTRIM(D.VENDNAME) [Vendor Name]

    , RTRIM(A.BUYERID) [Buyer ID]

    , COALESCE(C.ORCPTCOST, B.UNITCOST,0) [Unit Cost]

    , B.UOFM

    , ISNULL(C.QTYINVCD,0) [Qty Invoiced]

    , A.COMMNTID [PO Comment ID]

    , B.COMMNTID [Line Item Comment ID]

    , CASE B.POLNESTA

    WHEN 1 THEN 'New'

    WHEN 2 THEN 'Released'

    WHEN 3 THEN 'Change Order'

    WHEN 4 THEN 'Received'

    WHEN 5 THEN 'Closed'

    WHEN 6 THEN 'Cancelled'

    ELSE '#Error'

    END [PO Line Status]

    FROM POP10100 A

    JOIN POP10110 B ON A.PONUMBER = B.PONUMBER

    LEFT JOIN (SELECT PONUMBER, POLNENUM, SUM(QTYSHPPD) QTYSHPPD, SUM(QTYINVCD) QTYINVCD, AVG(ORCPTCOST) ORCPTCOST FROM POP10500 GROUP BY PONUMBER, POLNENUM) C ON B.PONUMBER = C.PONUMBER AND B.ORD = C.POLNENUM

    LEFT JOIN PM00200 D ON B.VENDORID = D.VENDORID

    ORDER BY B.PONUMBER, B.LineNumber

    -Trevor

  • Suggested answer
    Mahmoud Saadi Profile Picture
    Mahmoud Saadi 32,738 on at
    RE: Help with POP query for smartlist builder

    No, what I am actually indicating is that records from the header table could be normally duplicated when joined with the detail. Therefore, I don't think that using this script to build a "smart list" would be a good idea since it might result with "incorrect results" if not well user by end - users.

    Lets suppose that your smart list is exported into Excel by one of the users and inserted into Pivot Table for analysis purposes, see how "header" data will be duplicated (which is normal) and result with incorrect data.

    Therefore, I believe you could better use Crystal Reports "for instance" to publish your view, through which you could separate (by grouping by) the header from the details data, and ensure that no correct grouping will be perfored through "smart list" as shown above.

  • RE: Help with POP query for smartlist builder

    So, you are saying that this can't be done using a SQL view for use on a smartlist?

    P.S. sorry for the dellay in replying, got some server issues yesterday that got me bussy all day.

  • Suggested answer
    Mahmoud Saadi Profile Picture
    Mahmoud Saadi 32,738 on at
    RE: Help with POP query for smartlist builder

    When joining header and detail table, definition in the header will absolutely show in duplicated records depending on the no of details records, such as (Vendor ID, PO Number .. etc).  

    Most importantly, fields like "Quantity Ordered" on the purchase order, as well as the "Item Unit Cost" are duplicated. Therefore, Pivoting data on this report could result with incorrect numbers.

    Therefore, I would recommend publishing the report on Crystal report for instance, in order to split between the header and details data.

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

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans