我在查询的第一部分加入了GeneralJournalEntry
和GeneralJournalAccountEntry
。我现在很难对MainAccount
进行编码,因为我不确定如何正确使用DimensionProvider
类。
query = new Query();
qbdsGeneralJournalAccountEntry = query.addDataSource(tableNum(GeneralJournalAccountEntry));
qbr1 = qbdsGeneralJournalAccountEntry.addRange(fieldNum(GeneralJournalAccountEntry, LedgerAccount));
qbr1.value(queryValue('111111') + '*');
qbdsGeneralJournalEntry = qbdsGeneralJournalAccountEntry.addDataSource(tableNum(GeneralJournalEntry));
qbdsGeneralJournalEntry.relations(true);
qbdsGeneralJournalEntry.joinMode(JoinMode::InnerJoin);
if (_fromDate || _toDate)
{
qbdsGeneralJournalEntry.addRange(fieldnum(GeneralJournalEntry, AccountingDate)).value(queryRange(_fromDate, _toDate));
qbdsGeneralJournalEntry.addSortIndex(indexNum(GeneralJournalEntry, LedgerAccountingDateIdx));
qbdsGeneralJournalEntry.indexIsHint(true);
}
dimensionProvider = new DimensionProvider();
dimensionProvider.addAttributeRangeToQuery(
query
, qbdsGeneralJournalAccountEntry.name()
, fieldStr(GeneralJournalAccountEntr, LedgerDimension)
, DimensionComponent::DimensionAttribute
, _costCenterNumber
, "CostCenter");
我的所有行都被复制了..我想我再次添加GeneralJournalAccountEntry
数据源,这就是我有这种行为的原因。
我可以查看while qr.next部分中的成本中心值但是..有没有办法使用上述方法正确执行:addAttributeRangeToQuery
?
答案 0 :(得分:1)
好的,经过大量的尝试和搜索,再次尝试我得到了这个:
select firstOnly dimAttr where dimAttr.BackingEntityType == tableNum(DimAttributeOMCostCenter);
dimAttrNameCostCenter = dimAttr.Name;
query = new Query();
qbdsGeneralJournalEntry = query.addDataSource(tableNum(GeneralJournalEntry));
qbdsGeneralJournalAccountEntry = qbdsGeneralJournalEntry.addDataSource(tableNum(GeneralJournalAccountEntry));
qbdsGeneralJournalAccountEntry.relations(true);
qbdsGeneralJournalAccountEntry.joinMode(JoinMode::InnerJoin);
qbr1 = qbdsGeneralJournalAccountEntry.addRange(fieldNum(GeneralJournalAccountEntry, LedgerAccount));
qbr1.value(queryValue('111111') + '*');
if (_fromDate || _toDate)
{
qbdsGeneralJournalEntry.addRange(fieldnum(GeneralJournalEntry, AccountingDate)).value(queryRange(_fromDate, _toDate));
qbdsGeneralJournalEntry.addSortIndex(indexNum(GeneralJournalEntry, LedgerAccountingDateIdx));
qbdsGeneralJournalEntry.indexIsHint(true);
}
dimensionProvider = new DimensionProvider();
dimensionProvider.addAttributeRangeToQuery(query
, qbdsGeneralJournalAccountEntry.name()
, fieldStr(GeneralJournalAccountEntry, LedgerDimension)
, DimensionComponent::DimensionAttribute
, _costCenterNumber
, dimAttrNameCostCenter
, false);
现在有效!!我刚刚切换了dataSources:
GeneralJournalEntry
GeneralJournalAccountEntry
并将其加入" mother / father / header"表或其他任何东西:),即qbdsGeneralJournalEntry。所以,不再是双胞胎,没有重复。我仍然想知道为什么内连接表现得像这样......
明天我也会尝试为MainAccount使用addAttributeRangeToQuery,并在LedgerAccount上摆脱那个相当难看的范围。