Skip to main content
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

AP Account Statement report

(1) ShareShare
ReportReport
Posted on by 2,302
Hi Experts,
 
In Account Payable, I want to add PurchId in account statement report using below code.
 
But PuchId is not showing correct. Could you help me what missing in code.
internal final class AT_CustVendAccountStatementTmp_EventHandler
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [DataEventHandler(tableStr(CustVendAccountStatementIntTmp), DataEventType::Inserted)]
    public static void CustVendAccountStatementIntTmp_onInserted(Common sender, DataEventArgs e)
    {
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(classStr(VendAccountStatementIntDP), methodStr(VendAccountStatementIntDP, processReport))]
    public static void VendAccountStatementIntDP_Post_processReport(XppPrePostArgs args)
    {
        VendInvoiceJour     vendInvJr;
        VendAccountStatementIntDP dpInstance = args.getThis() as VendAccountStatementIntDP;
      
        CustVendAccountStatementIntTmp custVendAccountStatementIntTmp = dpInstance.getCustVendAccountStatementIntTmp();
        ttsbegin;
        while select forUpdate custVendAccountStatementIntTmp
        {
            select vendInvJr where vendInvJr.LedgerVoucher == custVendAccountStatementIntTmp.Voucher
                && vendInvJr.InvoiceDate == custVendAccountStatementIntTmp.TransDate && vendInvJr.InvoiceAccount == custVendAccountStatementIntTmp.AccountNum;

            custVendAccountStatementIntTmp.DocumentNum  =   vendinvjr.PurchId;
           
            custVendAccountStatementIntTmp.update();
        }
        ttscommit;
    }

}
 
 
Thanks,
Faiz
  • Verified answer
    faiz7049 Profile Picture
    2,302 on at
    AP Account Statement report
    Hi Andre and Amine,
     
    Issue has been resolved. The problem was in Purchase order there the invoice account and vendor code were different from each other.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    24,520 Super User 2025 Season 1 on at
    AP Account Statement report
     
    Try this code :
    while select forUpdate custVendAccountStatementIntTmp
    {
        vendInvJr = VendInvoiceJour::findFromVendTrans(custVendAccountStatementIntTmp.Invoice, custVendAccountStatementIntTmp.TransDate, custVendAccountStatementIntTmp.AccountNum, false, custVendAccountStatementIntTmp.Voucher);
        if(!vendInvJr)
        {
            vendInvJr = VendInvoiceJour::findFromVendTrans(custVendAccountStatementIntTmp.Invoice, custVendAccountStatementIntTmp.TransDate, custVendAccountStatementIntTmp.InvoiceAccount, false, custVendAccountStatementIntTmp.Voucher);
        }
        custVendAccountStatementIntTmp.DocumentNum  =   vendinvjr.PurchId;
               
        custVendAccountStatementIntTmp.update();
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • André Arnaud de Calavon Profile Picture
    296,042 Super User 2025 Season 1 on at
    AP Account Statement report
    Hi Faiz,

    When reading your reply, I wonder of you already found the culprit or is there a pending question?
  • faiz7049 Profile Picture
    2,302 on at
    AP Account Statement report
    Thank. Code is working only issue was there were different account for vendor account and invoice account in purchase order.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 171 Super User 2025 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 140 Super User 2025 Season 1

#3
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 127 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans