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)

X++ logic to calculate Outstanding Amount

(0) ShareShare
ReportReport
Posted on by 2,172

Hi All,

This is my table(below), here i should calculate the "cash advance outstanding" based on the "Requisition date"  in Ascending order for the person , and i should start with zero outstanding, if i select first date, the outstanding amount(OA) for the first date should be zero, then for the second date, it should show the first date outstanding amount, and for the third date it should show by adding the 1st+2nd date OA and so on..

How to achieve this logic by x++. Please share the syntax.

Ex.,

(if i select "RA-001607" then it should sum the "Req cash advance" for the Requisition date, which are all lesser than "26/01/2015")

RequisitionNumber HcmPersonnelNum ReqCashAdvance RequisitionDate CashAdvanceOutstanding
RA-001315 91000091 5,000.00 14/01/2015 0.00
RA-001316 91000091 5,000.00 14/01/2015 0.00
RA-001546 91000091 3,000.00 22/01/2015 0.00
RA-001607 91000091 7,000.00 26/01/2015 0.00
RA-001772 91000091 3,000.00 03/02/2015 0.00
RA-001773 91000091 2,250.00 03/02/2015 0.00
RA-003545 91000091 5,200.00 28/05/2015 0.00
RA-003590 91000091 0.00 01/06/2015 0.00
RA-003593 91000091 5,200.00 01/06/2015 0.00

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    If I have get you correctly then try the following query:

    MainTable mainTable;// Replace with your Table variable
    MainTable groupTable; // Replace with your Table variable

    while select forupdate mainTable
    {
    select sum(ReqCashAdvance) from groupTable
    where groupTable.RequisitionDate < mainTable.groupTable.RequisitionDate;
    ttsbegin;
    mainTable.CashAdvanceOutstanding = groupTable.ReqCashAdvance;
    mainTable.update();
    ttsCommit;
    }

    Result:

    RequisitionNumber HcmPersonnelNum ReqCashAdvance RequisitionDate CashAdvanceOutstanding
    RA-001315 91000091 5,000.00 14/01/2015 0
    RA-001316 91000091 5,000.00 14/01/2015 0
    RA-001546 91000091 3,000.00 22/01/2015 10000
    RA-001607 91000091 7,000.00 26/01/2015 13000
    RA-001772 91000091 3,000.00 3/2/2015 20000
  • Community Member Profile Picture
    on at

    Thanks for giving solution.It will help us.

  • Anand AX Profile Picture
    2,172 on at

    Hi

    Thank you so much for the solution.

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