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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Want to showing value for previous day if none exist for given date

(0) ShareShare
ReportReport
Posted on by 371

i have written the logic in this i get the item transaction as per date but i want to show the date by date one by one on which the transaction not done so it will automatically show the  uper value 

for example transa date 21/04/2016 qty 2000  and next trans date is 24/04/2016 qty 1200

so code will run like this  21/04/2016  -2000

                                         22/04/2016  - 2000

                                          23/04/2016  -2000

                                         24/04/2016 - 3200

like this i want to show on info

static void itemtransactionvinay(Args _args)
{
InventTrans InventTrans;
int qty,onHandTotal,c,i,diff;
ItemId ItemId;
TransDate start, finish;
InventTable InventTable;
;

start = str2date("04/21/2016", 213);
finish = str2date("06/23/2016", 213);

{

i++;
{
while select InventTable where InventTable.ItemId=="D0001"
join InventTrans where InventTrans.ItemId == InventTable.ItemId && InventTrans.DatePhysical >= start
&& InventTrans.DatePhysical <= finish
&& (InventTrans.StatusIssue==StatusIssue::Deducted || InventTrans.StatusIssue==StatusIssue::Sold || InventTrans.StatusIssue==StatusIssue::OnOrder || InventTrans.StatusIssue==StatusIssue::None
|| InventTrans.StatusReceipt == StatusReceipt::Purchased ||InventTrans.StatusReceipt == StatusReceipt::None )
{

qty += InventTrans.Qty;
ItemId = InventTrans.ItemId;

info(strFmt("ItemId::%1---Date::%2---qty::%3", ItemId,InventTrans.DatePhysical,qty));
start+=1;
}
}
}
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,938 Most Valuable Professional on at

    I would do something like this (it's pseudocode, not any actual programming language):

    d1 = dateStart
    
    until d1 == dateEnd
        d1 +=1
        find trans for d1
        if exists
            value = trans.qty
        // else keep the previous value
    	
        print d1, value
  • CU02060633-1 Profile Picture
    371 on at

    Thanku @martin but can you please write or suggest this in my code please..

  • Verified answer
    Martin Dráb Profile Picture
    239,938 Most Valuable Professional on at

    The main problem I see is that your loop iterates transactions, not dates, so you'll never get anything for days without transactions. If you want to use your logic instead of what I suggested, you'll have to store results in some collection and add values for "gaps" by some additional code.

  • CU02060633-1 Profile Picture
    371 on at

    ok i will try but if u have some thing more to explore in this pls suggest me...

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sanhthosh.Kumar.K Profile Picture

Sanhthosh.Kumar.K 2

#2
Raed Salah Bzour Profile Picture

Raed Salah Bzour 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans