Microsoft DynamicsFree generatorPDF, Excel, Word exportMicrosoft Dynamics GP

Dynamics GP AR Aging SQL Query Generator

Receivables aging is the report every GP controller runs and every migration must reconcile. This generator writes a clean SQL aging query over RM20101 and RM00101 that you can run in SSMS or put behind a report.

Fill in

The GP company database name (INTERID), for example TWO for the sample company.

Optional. Clear the field to include all customer classes.

Generated code
Download:

Aging by customer

USE [TWO];
GO

WITH open_items AS (
    SELECT
        o.CUSTNMBR,
        o.DUEDATE,
        CASE WHEN o.RMDTYPAL >= 7 THEN -o.CURTRXAM ELSE o.CURTRXAM END AS signed_amt,
        DATEDIFF(day, o.DUEDATE, '2026-09-30') AS days_past_due
    FROM dbo.RM20101 o
    WHERE o.VOIDSTTS = 0
      AND o.CURTRXAM <> 0
      AND o.DOCDATE <= '2026-09-30'
)
SELECT
    RTRIM(c.CUSTNMBR) AS customer_id,
    RTRIM(c.CUSTNAME) AS customer_name,
    SUM(CASE WHEN i.days_past_due <= 0 THEN i.signed_amt ELSE 0 END) AS current_not_due,
    SUM(CASE WHEN i.days_past_due BETWEEN 1 AND 30 THEN i.signed_amt ELSE 0 END) AS days_1_to_30,
    SUM(CASE WHEN i.days_past_due BETWEEN 30 + 1 AND 60 THEN i.signed_amt ELSE 0 END) AS days_30_to_60,
    SUM(CASE WHEN i.days_past_due BETWEEN 60 + 1 AND 90 THEN i.signed_amt ELSE 0 END) AS days_60_to_90,
    SUM(CASE WHEN i.days_past_due > 90 THEN i.signed_amt ELSE 0 END) AS over_90,
    SUM(i.signed_amt) AS total_open
FROM open_items i
JOIN dbo.RM00101 c ON c.CUSTNMBR = i.CUSTNMBR
WHERE 1 = 1
  AND c.CUSTCLAS = 'USA-ILMO-T1'
GROUP BY c.CUSTNMBR, c.CUSTNAME
HAVING SUM(i.signed_amt) <> 0
ORDER BY total_open DESC;

Read-only SELECT. In RM20101, RMDTYPAL values 7 and above are credit-type documents (credit memos, returns, payments), which is why they are negated; confirm against your RM setup. CURTRXAM is the current balance in the originating currency. This query reflects the balance today, not a true historical as-of balance, because applications after the as-of date are not unwound. Test on a copy first.

Need GP reports on a new platform?

An optional review of which GP reports to rebuild, retire or archive.

Optional. The tool and every export work without this. No spam.

How to use the generator

Enter the company database, the as-of date and the three bucket edges. Copy the SQL into SQL Server Management Studio, connect to the GP instance and run it. The optional filter lets you narrow to a customer class. The output has one row per customer with current, three aged buckets, over the last bucket and a total.

  • Use read-only SQL permissions for the account that runs it
  • Compare the grand total to the GP Aged Trial Balance report
  • Export the result set to Excel for the month-end pack

How the query works

It reads open items from RM20101, the receivables open transaction table, excludes voided documents and zero balances, signs credit documents negatively and computes days past due as the difference between the due date and the as-of date. Conditional SUM expressions then place each amount in a bucket. Joining to RM00101 adds the customer name and lets you filter by class.

Reconciling against GP

Totals should tie to the GP Aged Trial Balance run with the same date type (due date versus document date) and the same options for unapplied credits. Differences usually come from aging by document date instead of due date, foreign currency documents, or history that was removed. Fix the definition first before suspecting data.

Common mistakes

Do not sum ORTRXAMT, the original amount, when you want the open balance. Do not forget that credit documents carry positive amounts in GP and need signing. If you use multicurrency, add currency columns rather than adding totals across currencies.

Frequently Asked Questions

Which GP versions does this work with?

RM20101 and RM00101 exist in all modern GP releases, from GP 2010 through current. Column names used here (CUSTNMBR, DUEDATE, CURTRXAM, RMDTYPAL, VOIDSTTS) are long standing. Always test against your own database since customisations can differ.

Why do my totals not match the GP report?

Check the aging date basis (due date versus document date), whether the GP report includes unapplied payments and credits, and whether it uses the functional or originating currency. Match those settings, then compare again.

Can I run this on production?

It is a SELECT, so it does not change data, but heavy queries can slow users. Run it against a restored copy or in a quiet period, and use a read-only login.

How do I add salesperson or territory?

Add the SLPRSNID or TERRITRY columns from RM00101 to the select list and group by clause. Those columns are on the customer master, so no extra joins are needed.

If you need aging, cash and exposure reports rebuilt on a successor ERP or a private reporting layer, we can help build and reconcile them against your GP numbers.