// USR Changed on 05 七月 2012 at 15:19:34 by Jimmy Xie
static void THK_queryMultipleValue(Args _args)
{
query q = new query();
queryRun qr;
queryBuildRange qbr;
queryBuildDataSource qbds;
TransDate AsofDate = systemdateget();
projId projId = "30001";
str criteria;
name projAdjustRefId = "01130850_001";
InventTrans InventTrans;
int i;
;
qbds = q.addDataSource(tablenum(InventTrans));
/*
qbds.addRange(fieldnum(InventTrans,DateFinancial)).value(queryRange(dateNull(),AsofDate));
qbds.addRange(fieldnum(InventTrans,TransType)).value(queryValue(InventTransType::Project));
qbds.addRange(fieldnum(InventTrans,ProjId)).value(projId);
qbds.addRange(fieldnum(InventTrans,projAdjustRefId)).value(projAdjustRefId);
*/
qbds.addSelectionField(fieldnum(InventTrans, Qty),SelectionField::Sum);
qbds.orderMode(orderMode::GroupBy);
qbds.addSortField(fieldnum(InventTrans,DateFinancial));
qbds.addSortField(fieldnum(InventTrans,ItemId));
//注意:
//条件务必保持有值,不然记录会为空;如果是字符串值必须加上双引号,枚举,日期值不需要
qbr = SysQuery::findOrCreateRange(qbds,fieldnum(InventTrans,DataAreaid));
criteria = strFmt(
'(%1) && (%1<=%2) && (%3==%4) && (%5=="%6") && (%7=="%8")',
fieldStr(InventTrans, DateFinancial), // %1 - ok!
Date2StrXpp(AsofDate), // %2 - ok!
fieldStr(InventTrans, TransType), //%3
any2int(InventTransType::Project), //%4
fieldStr(InventTrans, ProjId), //%5
projId , //6
fieldStr(InventTrans, projAdjustRefId),//%7 字符串
projAdjustRefId //8
);
qbr.value(criteria);
qr = new queryRun(q);
info(qr.query().dataSourceNo(1).toString());
while (qr.next())
{
InventTrans = qr.getNo(1);
i++;
info(strfmt("%1 - %2 - %3 [%4]",i,InventTrans.ItemId,InventTrans.DateFinancial,InventTrans.Qty));
}
}
没有评论:
发表评论