AX 2012 分组依据 table
AX 2012 Group by with common table
如何按具有特定字段的公共 table 进行分组?
我在 (dt.fieldname2Id('BatchNo'))
上遇到语法错误
这是我的代码:
Common common;
SysDictTable dt;
dt = SysDictTable::newName('Table1');
common = dt.makeRecord();
while select count(RecId) from common
group by common.(dt.fieldname2Id('BatchNo')) //syntax Error here
where common.(dt.fieldname2Id('flag'))==1
{
info(int642str(Common.Recid));
}
您可以使用 Query
代替:
Common common;
SysDictTable dt;
Query query = new Query();
QueryBuildDataSource qbds;
QueryRun queryRun;
dt = SysDictTable::newName('SalesTable');
common = dt.makeRecord();
qbds = query.addDataSource(common.TableId);
qbds.addGroupByField(dt.fieldname2Id('CustAccount'));
queryRun = new QueryRun(query);
while (queryRun.next())
{
...
}
如何按具有特定字段的公共 table 进行分组?
我在 (dt.fieldname2Id('BatchNo'))
这是我的代码:
Common common;
SysDictTable dt;
dt = SysDictTable::newName('Table1');
common = dt.makeRecord();
while select count(RecId) from common
group by common.(dt.fieldname2Id('BatchNo')) //syntax Error here
where common.(dt.fieldname2Id('flag'))==1
{
info(int642str(Common.Recid));
}
您可以使用 Query
代替:
Common common;
SysDictTable dt;
Query query = new Query();
QueryBuildDataSource qbds;
QueryRun queryRun;
dt = SysDictTable::newName('SalesTable');
common = dt.makeRecord();
qbds = query.addDataSource(common.TableId);
qbds.addGroupByField(dt.fieldname2Id('CustAccount'));
queryRun = new QueryRun(query);
while (queryRun.next())
{
...
}