static void Job23(Args _args)
{
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
QueryRun queryRun;
Query query;
Qty total;
InventTrans inventTrans;
inventDim inventDim;
query = new Query();
queryBuildDataSource = query.addDataSource(tableNum(InventTrans));
queryBuildDataSource.addSelectionField(fieldNum(InventTrans,Qty),SelectionField::Sum);
queryBuildRange = queryBuildDataSource.addRange(fieldNum(InventTrans,ItemId));
queryBuildDataSource = queryBuildDataSource.addDataSource(tableNum(InventDim));
queryBuildDataSource.addGroupByField(fieldNum(InventDim,InventBatchId));
queryBuildDataSource.relations(true);
queryRun = new QueryRun(query);
if (queryRun.prompt())
{
while (queryRun.next())
{
inventTrans = queryRun.get(tableNum(InventTrans));
inventDim = queryRun.get(tableNum(inventDim));
info(strFmt("Batch %1, qty %2",inventDim.inventBatchId, inventTrans.qty));
}
}
}
{
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
QueryRun queryRun;
Query query;
Qty total;
InventTrans inventTrans;
inventDim inventDim;
query = new Query();
queryBuildDataSource = query.addDataSource(tableNum(InventTrans));
queryBuildDataSource.addSelectionField(fieldNum(InventTrans,Qty),SelectionField::Sum);
queryBuildRange = queryBuildDataSource.addRange(fieldNum(InventTrans,ItemId));
queryBuildDataSource = queryBuildDataSource.addDataSource(tableNum(InventDim));
queryBuildDataSource.addGroupByField(fieldNum(InventDim,InventBatchId));
queryBuildDataSource.relations(true);
queryRun = new QueryRun(query);
if (queryRun.prompt())
{
while (queryRun.next())
{
inventTrans = queryRun.get(tableNum(InventTrans));
inventDim = queryRun.get(tableNum(inventDim));
info(strFmt("Batch %1, qty %2",inventDim.inventBatchId, inventTrans.qty));
}
}
}
No comments:
Post a Comment