以下のx ++クエリのサンプルをご覧ください。しかし、あなたは標準AXフィールドにPurchIdとJournalIdは異なる長さを有し、そして次のエラーを取得することを心に留めなければなりません:
There is a field mismatch in the union query. Field JournalId is not compatible with field PurchId.
Query query;
QueryBuildDataSource qbdsInventJournalTrans;
QueryBuildDataSource qbdsPurchLine;
QueryBuildRange qbrInventJournalTrans;
QueryBuildRange qbrPurchLine;
;
query = new Query();
query.queryType(QueryType::Union);
qbdsInventJournalTrans = query.addDataSource(tableNum(InventJournalTrans));
qbdsInventJournalTrans.unionType(UnionType::UnionAll); // Include duplicate records
qbdsInventJournalTrans.fields().dynamic(false);
qbdsInventJournalTrans.fields().clearFieldList();
qbdsInventJournalTrans.fields().addField(fieldNum(InventJournalTrans, AssetId));
qbdsInventJournalTrans.fields().addField(fieldNum(InventJournalTrans, ItemId));
//qbdsInventJournalTrans.fields().addField(fieldNum(InventJournalTrans, JournalId));
qbrInventJournalTrans = qbdsInventJournalTrans.addRange(fieldNum(InventJournalTrans, AssetId));
qbrInventJournalTrans.value(SysQuery::valueNotEmptyString());
qbdsPurchLine = query.addDataSource(tableNum(PurchLine));
qbdsPurchLine.unionType(UnionType::UnionAll); // Include duplicate records
qbdsPurchLine.fields().dynamic(false);
qbdsPurchLine.fields().clearFieldList();
qbdsPurchLine.fields().addField(fieldNum(PurchLine, AssetId));
qbdsPurchLine.fields().addField(fieldNum(PurchLine, ItemId));
//qbdsPurchLine.fields().addField(fieldNum(PurchLine, PurchId));
qbrPurchLine = qbdsPurchLine.addRange(fieldNum(PurchLine, AssetId));
qbrPurchLine.value(SysQuery::valueNotEmptyString());
あなたはAOTクエリHow to: Combine Data Sources
を作成する必要がある場合は、このリンクを参照してください
[概要の表示](https://msdn.microsoft.com/en-us/library/cc634339(v= ax.50).aspx)と[How to:データソースの結合](https ://msdn.microsoft.com/en-us/library/cc605991(v = ax.50).aspx)? –