protected void createReportLines() { Query q; QueryRun qr; QueryBuildDataSource qbds, qbdsInventTrans; RecId dimAttrRecId = AgreementHeaderExt_RU::getAgreementDimensionAttribute(); q = new Query(); qbdsInventTrans = q.addDataSource(tableNum(InventTrans)); findOrCreateRange_W(qbdsInventTrans, fieldNum(InventTrans, TableId), strFmt(issueReceiptValue, qbdsInventTrans.name(), enum2int(StatusIssue::Sold), enum2int(StatusReceipt::Purchased))); findOrCreateRange_W(qbdsInventTrans, fieldNum(InventTrans, DateFinancial), queryRange(commReportJour.StartDate, commReportJour.EndDate)); qbds = qbdsInventTrans.addDataSource(tableNum(InventTransOrigin)); qbds.addLink(fieldNum(InventTrans, InventTransOrigin), fieldNum(InventTransOrigin, RecId)); qbds.joinMode(JoinMode::InnerJoin); qbds.fetchMode(QueryFetchMode::One2One); qbds = qbds.addDataSource(tableNum(CustInvoiceTrans)); qbds.addLink(fieldNum(InventTransOrigin, InventTransId), fieldNum(CustInvoiceTrans, InventTransId)); qbds.addLink(fieldNum(InventTrans, InvoiceId), fieldNum(CustInvoiceTrans, InvoiceId), qbdsInventTrans.name()); qbds.joinMode(JoinMode::InnerJoin); qbds = qbds.addDataSource(tableNum(CustInvoiceJour)); qbds.relations(true); qbds.joinMode(JoinMode::InnerJoin); findOrCreateRange_W(qbds, fieldNum(CustInvoiceJour, InvoiceAccount), queryValue(commReportJour.PartnerCode)); SysQuery::addDimensionAttributeRange(q, qbds.name(), fieldStr(CustInvoiceJour, DefaultDimension), DimensionComponent::DimensionAttribute, commReportJour.AgreementId, DimensionAttribute::find(dimAttrRecId).Name); qbds = qbds.addDataSource(tableNum(CustInvoiceJour_RU)); qbds.relations(true); qbds.joinMode(JoinMode::ExistsJoin); findOrCreateRange_W(qbds, fieldNum(CustInvoiceJour_RU, InventProfileType_RU), con2Str([InventProfileType_RU::CommissionAgent, InventProfileType_RU::CommissionPrincipalAgent])); qbds = qbdsInventTrans.addDataSource(tableNum(InventDim)); qbds.addLink(fieldNum(InventTrans, InventDimId), fieldNum(InventDim, InventDimId)); qbds.joinMode(JoinMode::InnerJoin); qbds.fetchMode(QueryFetchMode::One2One); qr = new QueryRun(q); while (qr.next()) { inventTrans = qr.get(tableNum(InventTrans)); inventTransOrigin = qr.get(tableNum(InventTransOrigin)); custInvoiceTrans = qr.get(tableNum(CustInvoiceTrans)); custInvoiceJour = qr.get(tableNum(CustInvoiceJour)); inventDim = qr.get(tableNum(inventDim)); this.processVendShipments(); } }
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Sunday, June 16, 2024
D365FO: Add financial dimension range in Query using X++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment