Wednesday, July 14, 2021

QueryBuildFieldList in SSRS Dp class in D365FO.

For improving performanance of report we are using QueryBuildFieldList.        
        Query query; QueryBuildDataSource qbds; str testsalesman, teststore; List storeList = new List(Types::String), salesmanList = new List(Types::String); QueryBuildFieldList fldList_RetailTransactionSalesTrans; Map fieldMapping; ; contract = this.parmDataContract() as BranchAndSalesmanInvoiceContract;// contract class fromDate = contract.parmFromDate(); toDate = contract.parmToDate(); salesmanList = contract.parmSalesmanId(); storeList = contract.parmstoreId(); testsalesman = salesmanList.toString(); teststore = storeList.toString(); teststore = strRem(teststore,"<"); teststore = strRem(teststore,">"); query = new Query(); qbds = query.addDataSource(tableNum(BranchAndSalesmanInvoiceStagging)); // Main table. if(salesmanList) { qbds.addRange(fieldNum(BranchAndSalesmanInvoiceStagging, Salesman)).value(testsalesman); } if(storeList) { qbds.addRange(fieldNum(BranchAndSalesmanInvoiceStagging, Store)).value(teststore); } qbds.addGroupByField(fieldNum(BranchAndSalesmanInvoiceStagging, Store)); qbds.addGroupByField(fieldNum(BranchAndSalesmanInvoiceStagging, Salesman)); qbds.addGroupByField(fieldNum(BranchAndSalesmanInvoiceStagging, ReceiptId)); ttsbegin; delete_from branchAndSalesmanInvoiceTmp;// temp table buffer. ttscommit; qbds.fields().clearFieldList(); fldList_RetailTransactionSalesTrans = qbds.fields(); fldList_RetailTransactionSalesTrans.addField(fieldNum(BranchAndSalesmanInvoiceStagging, Salesman)); fldList_RetailTransactionSalesTrans.addField(fieldNum(BranchAndSalesmanInvoiceStagging, Store)); fldList_RetailTransactionSalesTrans.addField(fieldNum(BranchAndSalesmanInvoiceStagging, ReceiptId)); fldList_RetailTransactionSalesTrans.dynamic(QueryFieldListDynamic::No); fieldMapping = new Map(Types::String, Types::Container);// BranchAndSalesmanInvoiceTmp - Main temp table. fieldMapping.insert(fieldStr(BranchAndSalesmanInvoiceTmp, EmpId), [qbds.uniqueId(), fieldStr(BranchAndSalesmanInvoiceStagging, Salesman)]); fieldMapping.insert(fieldStr(BranchAndSalesmanInvoiceTmp, Store), [qbds.uniqueId(), fieldStr(BranchAndSalesmanInvoiceStagging, store)]); fieldMapping.insert(fieldStr(BranchAndSalesmanInvoiceTmp, ReceiptId), [qbds.uniqueId(), fieldStr(BranchAndSalesmanInvoiceStagging, ReceiptId)]); query::insert_recordset(branchAndSalesmanInvoiceTmp, fieldMapping, query);// Inserting data into temp table.
Keep daxing!!

No comments:

Post a Comment