web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Match Invoice Receipt to PO Line Receipt SQL

(0) ShareShare
ReportReport
Posted on by 275

I have been working on making a way in SQL to match the invoice line receipt to the PO line reciept. My boss wants me to have a report that can compare an item's receipt with the date we received the receipt. GP does this on a line-by-line basis so there must be a connection somewhere but I'm having trouble consistently getting it right. Here's what I have so far that returns a great number of correct lines but is still not accurate enough:

select isnull(
case when
(select top(1) glpostdt from pop30300 where poprctnm =
(select top(1) poprctnm from pop10500 where itemnmbr = a.itemnmbr and ponumber = a.ponumber
and appytype = 3 and polnenum = a.polnenum and qtyinvcd = a.qtyshppd order by daterecd asc)) is null then
(select top(1) glpostdt from pop30300 where poprctnm =
(select top(1) poprctnm from pop10500 where itemnmbr = a.itemnmbr and ponumber = a.ponumber
and appytype = 3 and polnenum = a.polnenum order by daterecd asc)) else
(select top(1) glpostdt from pop30300 where poprctnm =
(select top(1) poprctnm from pop10500 where itemnmbr = a.itemnmbr and ponumber = a.ponumber
and appytype = 3 and polnenum = a.polnenum and qtyinvcd = a.qtyshppd order by daterecd asc)) end
, '2/22/2222') as invodate, isnull(
case when
(select top(1) glpostdt from pop30300 where poprctnm =
(select top(1) poprctnm from pop10500 where itemnmbr = a.itemnmbr and ponumber = a.ponumber
and appytype = 3 and polnenum = a.polnenum and qtyinvcd = a.qtyshppd order by daterecd asc)) is null then
'U' else
case
when
(select count(poprctnm) from pop10500 where itemnmbr = a.itemnmbr and ponumber = a.ponumber
and appytype = 1 and polnenum = a.polnenum and qtyshppd = a.qtyshppd) > 1 then
'M' else '' end end
, '') as flag,
daterecd, poprctnm as receipt,
itemnmbr, (select itemdesc from iv00101 where itemnmbr = a.itemnmbr) as itemdesc, qtyshppd as qty, pchrptct as cost,
vendorid, (select vendname from pm00200 where vendorid = a.vendorid) as vendname,
isnull((select top(1) vnddocnm from pop30300 where poprctnm =
(select top(1) poprctnm from pop10500 where itemnmbr = a.itemnmbr and ponumber = a.ponumber
and appytype = 3 and polnenum = a.polnenum order by daterecd asc)), 'Cannot Find') as vendordoc
from pop10500 a
where appytype = 1

The "U" and "M" flags mean that the connection is unkown or it found multiple items for a PO and warns that the invoice receipt date is likely inaccurate. Any help is appreciated.

*This post is locked for comments

I have the same question (0)
  • Sudin B Profile Picture
    370 on at

    I don't fully understand requirements, however, you could consider looking into POP10600 table as well.

  • Sagi88 Profile Picture
    2,250 on at

    Hi Matthew.

    This is a view I usually use:

    Select a.POPIVCNO, a.IVCLINNO, a.POPRCTNM, a.RCPTLNNM,
    b.VENDORID, b.VENDNAME, b.VNDDOCNM  AS [Invoice No], b.receiptdate as [Invoice Date],
    c.VNDDOCNM as [Bill of Lading], c.receiptdate as [Date Received],
    d.ITEMNMBR, d.ITEMDESC, d.VNDITNUM, d.VNDITDSC,
    a.QTYINVCD, e.QTYSHPPD, e.QTYREJ From POP10600 a
    INNER JOIN POP30300 b ON a.POPIVCNO = b.POPRCTNM
    INNER JOIN POP30300 c ON a.POPRCTNM = c.POPRCTNM
    INNER JOIN POP30310 d on a.POPRCTNM = d.POPRCTNM and a.RCPTLNNM = d.RCPTLNNM
    INNER JOIN POP10500 e on a.POPRCTNM = e.POPRCTNM and a.RCPTLNNM = e.RCPTLNNM   

    Hope this helps

  • Matthew Magrum Profile Picture
    275 on at

    Thanks, I will check it out and let you know!

  • Matthew Magrum Profile Picture
    275 on at

    This looks dead-on, thanks! I'm going to forward this to my boss as well but I think this is it! Thank you!

  • Ron Wilson Profile Picture
    6,010 on at

     Sagi88...

    Thanks so much for the contribution.  Can I add this to my blog?

    Ron

  • Sagi88 Profile Picture
    2,250 on at

    No problem Ron.

  • Ron Wilson Profile Picture
    6,010 on at

     Thank so much Sagi88!

    http://rldu.wordpress.com/2010/05/03/from-the-community-5-match-invoice-receipt-to-po-line-item/

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans