2013年4月12日星期五
How to using query get inventory AvailPhysical qty
void inventOnHandQuery(ItemID _itemId,InventBatchId _batchId)
{
Query g_Query;
QueryBuildDataSource qbdISum,qbdIDim;
QueryBuildRange qbr;
InventSum inventSum;
QueryRun locQueryRun;
Qty onHandQty;
Container dimActiveFields;
int i = 1;
InventDim inventDim;
;
dimActiveFields = InventDimSearch::activeFields(InventTable::find(_itemId).DimGroupId);
g_Query = new Query();
qbdISum = g_Query.addDataSource(tablenum(inventSum));
qbdISum.addSortField(fieldNum(inventSum,ItemId));
qbr = qbdISum.addRange(fieldnum(inventSum,ItemId));
qbr.value(_itemId);
qbdIDim = qbdISum.addDataSource(tablenum(InventDim));
qbdIDim.relations(true);
qbdIDim.addRange(fieldNum(inventDim,InventBatchId)).value(_batchId);
while(i <= conlen(dimActiveFields))
{
qbdIDim.addSortField(conpeek(dimActiveFields,i));
i++;
}
qbdISum.addRange(fieldNum(inventSum,AvailPhysical)).value(SysQuery::valueNot(0));
qbdISum.addSelectionField(fieldNum(inventSum,AvailPhysical),SelectionField::Sum);
qbdIDim.orderMode(OrderMode::GroupBy);
locQueryRun = new QueryRun(g_Query);
while(locQueryRun.next())
{
inventSum = locQueryRun.get(tablenum(InventSum));
inventDim = locQueryRun.get(tablenum(InventDim));
onHandQty = inventSum.AvailPhysical;
if(InventParameters::find().InventLocationId_DNT != inventDim.InventLocationId)
{
if(onceFlag)
{
onceFlag = false;
this.createInventJournalTable();
}
numOfLines++;
this.createInventJournalTrans(journalTable.JournalId,_itemId,onHandQty,inventDim);
}
}
return ;
}
订阅:
博文评论 (Atom)
没有评论:
发表评论