Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

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

$
0
0

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.

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. 

[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.StatusIssue == StatusIssue::Sold;
		
		
                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();
            }
        }

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


Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>