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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Open Vendor Invoices - SQL QUERY

(0) ShareShare
ReportReport
Posted on by

Hi All,

I would like to get the same result (SQL QUERY) as in Accounts Payable - Common - Vendor Invoices - Open Vendor Invoices datagrid but my SQL query returns more lines than in the datagrid.

Export to Excel = 1421 lines

SQL Query = 1575 lines

Here is my query :

SELECT 'Open Vendor Invoices' AS INVOICETYPE
     ,VTO.ACCOUNTNUM
     ,VTO.AMOUNTCUR
     ,VTO.AMOUNTMST
     ,VTO.DUEDATE
     ,VTO.TRANSDATE
     ,VTR.INVOICE
FROM VENDTRANSOPEN VTO
JOIN VENDTRANS VTR ON VTO.REFRECID = VTR.RECID AND VTO.ACCOUNTNUM = VTR.ACCOUNTNUM
JOIN VENDTABLE VTA ON VTR.ACCOUNTNUM = VTA.ACCOUNTNUM
WHERE VTR.APPROVED = 1
OR VTR.TRANSTYPE = 36
OR VTR.TRANSTYPE = 3
OR VTR.TRANSTYPE = 14

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Would you like to read some theory behind all concept? probably that can help you to understand data structure

    community.dynamics.com/.../210639

    go though this and get back with your question, in case you face difficulty to fix this.

  • Suggested answer
    Brandon Wiese Profile Picture
    17,788 on at

    For starters, you should include DATAAREAID in your joins, and PARTITION if you're version of AX includes it.  You could have multiple vendors with the same ACCOUNTNUM but in different companies, and that mis-join could be exploding your data.

    Additionally, rather than use TRANSTYPE as a filter, join to VENDINVOICEJOUR, which are actual invoices.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans