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)

Inventory Management Report, inbound, outbound, onhand quantities between 2 dates

(0) ShareShare
ReportReport
Posted on by 282

hi everybody,

i need to create a report that will display the following fields for items in my inventory : 

as parameters : Starting Date, Ending Date, Warehouse

- ItemId,

- Qty onhand at starting date

- Qty onhand at Ending Date

- Qty of inbound (including transfers to the site en parameters as well as the purchase receipts and positive inventory adjustement )

- Qty of outbound  (including transfers from the site en parameters as well as the sold and negative inventory adjustement )

to do so,

1/ i first tried to garanty the instruction that returns the inventory onhand for an item based on date, after some research i found this :  

 inventSumDateDim= InventSumDateDim::newParameters( date, inventTransByItem.ItemId, inventDimCriteria, inventDimParm);

 onhandQty = (inventSumDateDim.postedQty() + inventSumDateDim.receivedQty() - inventSumDateDim.deductedQty());

this will allow me to calculate  the two fields : Qty onhand at starting date, Qty onhand at Ending Date

2 / Regarding the Qty of inbound and outbound i thought about this instruction : 

select sum(Qty)  from inventTransByItem
                    outer join configId, InventColorId, InventSizeId, InventStyleId from  inventDim
                    group by inventTransByItem.ItemId, inventTransByItem.inventdimId
                    where inventTransByItem.inventDimId == inventDim.inventdimId
                          && inventDim.inventLocationId == { location arg }
                          && inventTransByItem.DatePhysical <= { starting date arg}
                          && inventTransByItem.DatePhysical >= { ending date arg}
						  && inventTransByItem.StatusReceipt == StatusIssue::Sold /*  -- for the outbound qty*/
						  /* && inventTransByItem.StatusReceipt ==StatusReceipt::Purchased -- for the inbound qty * /

then all i have to do is to loop on every inventtrans between the two date grouping by item and storage dimension during the processData method of the Data Provider class of the report.

[SysEntryPointAttribute]
        public void processReport()
        {
            InventTrans                     inventTransByItem;
            InventDim                       inventDim;
        
            SPLBouclageStockContractDP      splBouclageStockContractDP;
        
        
            InventSumDateDim                inventSumDateDimStart;
            InventSumDateDim                inventSumDateDimEnd;
            InventDim                       inventDimCriteria;
            InventDimParm                   inventDimParm;
        
        
            splBouclageStockContractDP = this.parmDataContract();
        
            argLocation = splBouclageStockContractDP.parmInventLocationId();
            argSite= splBouclageStockContractDP.parminventSiteId();
        
            argStartDate = splBouclageStockContractDP.parmstartDate();
            argEndDate = splBouclageStockContractDP.parmEndDate();
        
        
        
             while select ItemId from inventTransByItem
                    outer join configId, InventColorId, InventSizeId, InventStyleId from  inventDim
                    group by inventTransByItem.ItemId, inventTransByItem.InventDimId
                    where inventTransByItem.inventDimId == inventDim.inventdimId
                          && inventDim.inventLocationId == argLocation && inventDim.InventSiteId == argSite
                          && inventTransByItem.DatePhysical <= argEndDate
                          && inventTransByItem.DatePhysical >= argStartDate
            {
        
				select sum(Qty) from inventTransByItemOutbound
                   group by inventTransByItemOutbound.ItemId, inventTransByItemOutbound.InventDimId
					where inventTransByItemOutbound.inventDimId == inventTransByItem.inventdimId
						   && inventTransByItemOutbound.ItemId == inventTransByItem.ItemId
                           && inventTransByItemOutbound.DatePhysical <= argEndDate
                           && inventTransByItemOutbound.DatePhysical >= argStartDate
						   && inventTransByItemOutbound.StatusIssue == StatusIssue::Sold;
						   
						   
				select sum(Qty) from inventTransByItemInbound
                   group by inventTransByItemInbound.ItemId, inventTransByItemInbound.InventDimId
					where inventTransByItemInbound.inventDimId == inventTransByItem.inventdimId
						  && inventTransByItemInbound.ItemId == inventTransByItem.ItemId
                          && inventTransByItemInbound.DatePhysical <= argEndDate
		                  && inventTransByItemInbound.DatePhysical >= argStartDate
						  && (inventTransByItemInbound.StatusReceipt == StatusReceipt::Purchase ||inventTransByItemInbound.StatusReceipt == StatusReceipt::Receipt) ; 
						   
				inventDimCriteria.InventColorId = inventDim.InventColorId; 
				inventDimCriteria.InventSizeId = inventDim.InventSizeId; 
				inventDimCriteria.InventStyleId = inventDim.InventStyleId; 
				inventDimCriteria.configId = inventDim.configId; 
				inventDimCriteria.InventSiteId = argSite; 
				inventDimCriteria.InventLocationId = argLocation; 
				
				inventDimParm.initFromInventDim(inventDimCriteria); 
				inventSumDateDimStart = InventSumDateDim::newParameters(argStartDate, inventTransByItem.ItemId, inventDimCriteria, inventDimParm); 
				inventSumDateDimEnd = InventSumDateDim::newParameters(argEndDate, inventTransByItem.ItemId, inventDimCriteria, inventDimParm); 
				
				splBouclageStockRDPTmp.ItemId = inventTransByItem.ItemId; 
				splBouclageStockRDPTmp.InventColorId = inventDim.InventColorId; 
				
				splBouclageStockRDPTmp.InventSizeId = inventDim.InventSizeId; 
				splBouclageStockRDPTmp.InventStyleId = inventDim.InventStyleId; 
				splBouclageStockRDPTmp.configId = inventDim.configId; 
				
				splBouclageStockRDPTmp.QtyStart = (inventSumDateDimStart.postedQty() + inventSumDateDimStart.receivedQty() - inventSumDateDimStart.deductedQty()); 
				splBouclageStockRDPTmp.QtyEnd = (inventSumDateDimEnd.postedQty() + inventSumDateDimEnd.receivedQty() - inventSumDateDimEnd.deductedQty()); 
				
				splBouclageStockRDPTmp.QtyInbound= inventTransByItemInbound.Qty; 
				splBouclageStockRDPTmp.QtyOutbound= inventTransByItemOutbound.Qty; 
				
				splBouclageStockRDPTmp.insert(); 
			} 
		}


Can anyone tell me if i am doing it wrong at step 1 or 2 ? besides when i am running the report i get an error telling me i am reaching the timeout !! Can my code be more optimized or i just need to increase the timeOut of the reporting services. 


Thank you in advance for every enhancement you can recommand me to acheive my goal.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    saad nadir Profile Picture
    282 on at

    after many tests, i figured out that first i should do "outer join" in my first select, but only "join", thats why i took the eternity to generate the report.

  • Verified answer
    Mehdi AMRANI Profile Picture
    1,422 on at

    Hi Saad,

    Try to activate the chineese inventory report, that gives you all this informations out of the box.

    Go to

    AOT > Item Menus > Outputs > InventoryStatusInPeriodByType_CN

    In the properties > CountryRegionCode Leave it Blank and drag the repport where ever you want.

    Best Regards,

    Mehdi AMRANI

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans