Useing x++ code Calculate period the on hand stock
Remark by Jimmy July 13th 2010
static void Jimmy_OnHandCalc(Args _args) { InventSumFinancial InventSumFinancial; InventSumDatePhysical InventSumDatePhysical = new InventSumDatePhysical(); InventSumDateValueReport InventSumDateValueReport; InventSumDateValue InventSumDateValue = new InventSumDateValue(); InventSum InventSum; qty OnHandQty; Date PhysicalDate = MkDate(30,4,2010); ItemId ItemId = 'BAG-1077-2';//10-1000 InventTable IT = InventTable::find(ItemId); ; InventSumDateValueReport = InventSumDateValueReport::newParameters(PhysicalDate,ItemId); OnHandQty = InventSumDateValueReport.inventoryValue(); print 'InventSumDateValueReport as below';//数量与库存价值均以物料实际交易日期为准则 print 'Qty:',InventSumDateValueReport.physicalQuantity(), ' Value:',InventSumDateValueReport.inventoryValue(); OnHandQty = 0; InventSumFinancial = InventSumFinancial::newInventTable(PhysicalDate,IT); OnHandQty = InventSumFinancial.value(); print 'InventSumFinancial as below';//数量与库存价值均以 财务实际交易日期为准则 print 'Qty:',InventSumFinancial.qty(), ' Value:',InventSumFinancial.value(); InventSumDatePhysical.parmItemId(ItemId); InventSumDatePhysical.parmPerDate(PhysicalDate); InventSumDatePhysical.init(); print 'InventSumDatePhysical as below';//没有库存价值 print 'Qty:',InventSumDatePhysical.physicalQuantity(); InventSumDateValue.parmItemId(ItemId); InventSumDateValue.parmPerDate(PhysicalDate); InventSumDateValue.init(); print 'InventSumDateValue as below'; // 库存价值不正确 print 'Qty:',InventSumDateValue.physicalQuantity(),' Value:',InventSumDateValue.inventoryValue(); print InventSumDateValue.estimatedInventValue(); pause; }
static void Jimmy_OnHandFindDim(Args _args) { /*** wrote by Jimmy on Dec. 1th 2010 按维度显示库存 InventSum 的newQuery 方法 */ query q; queryRun qr; InventSum inventSum; InventDim inventDim; InventDim inventDimValue; InventDimParm inventDimParmCriteria; inventDimParm inventDimParmGroupBy; inventSumDateValueReportDim inventSumDateValueReportDim; int i; ; //维度(Dimension)条件 inventDimValue.InventLocationId = "FPW"; inventDimValue.configId = "NZ-R"; inventDimValue.inventBatchId = "00000000-000000"; //维度显示(有效)参数 inventDimParmCriteria.ItemIdFlag = NoYes::Yes; inventDimParmCriteria.InventLocationIdFlag = NoYes::Yes; inventDimParmCriteria.ConfigIdFlag = NoYes::Yes; inventDimParmCriteria.InventBatchIdFlag = NoYes::Yes; //维度汇总参数 inventDimParmGroupBy.ItemIdFlag = NoYes::Yes; inventDimParmGroupBy.ConfigIdFlag = NoYes::Yes; inventDimParmGroupBy.InventLocationIdFlag = NoYes::Yes; inventDimParmGroupBy.InventBatchIdFlag = NoYes::Yes; q = new Query(); InventSum::newQuery(q,"10-1000",inventDimValue,inventDimParmCriteria,inventDimParmGroupBy); info(q.dataSourceNo(1).toString()); qr = new QueryRun(q); while (qr.next()) { inventDim = qr.get(tableNum(InventDim)); inventSum = qr.get(tableNum(InventSum)); i++; print inventDim.InventLocationId,' ',inventDim.inventBatchId,inventSum.AvailPhysical," ",inventSum.PhysicalInvent; } print i; pause; } /*** qty OnHand(ItemId _ItemId) { qty onHand; InventSum InventSum; InventDim InventDim; ; while select InventSum where InventSum.ItemId == _ItemId join InventDim where InventDim.InventDimId == InventSum.InventDimId && InventDim.InventLocationId != "RTV" && InventDim.InventLocationId != "REJECT" && InventDim.InventLocationId != "OBS" && InventDim.InventLocationId != "SALES" { onHand += InventSum.PhysicalInvent; } return onHand; } */