Показать сообщение отдельно
Старый 19.01.2021, 23:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
a33ik: RPD and Query (DateFrom, DateTo) based SSRS report, AX classes
Источник: http://daxonline.org/1715-rpd-and-qu...x-classes.html
==============

Contract class:
[ DataContractAttribute]class VKSalesQuotationDailyContract extends SrsReportRdlDataContract implements SysOperationValidatable{ TransDate dateFrom; TransDate dateTo; NoYes showDetails; [ DataMemberAttribute('dateFrom'), SysOperationLabelAttribute(literalStr("@SYS35369")), SysOperationControlVisibilityAttribute(true) ] public TransDate parmDateFrom(TransDate _dateFrom = dateFrom) { dateFrom = _dateFrom; return dateFrom; } [ DataMemberAttribute('dateTo'), SysOperationLabelAttribute(literalStr("@SYS114982")), SysOperationControlVisibilityAttribute(true) ] public TransDate parmDateTo(TransDate _dateTo = dateTo) { dateTo = _dateTo; return dateTo; } [ DataMemberAttribute('ShowDetails'), SysOperationLabelAttribute(literalStr("@SYS8811")), SysOperationControlVisibilityAttribute(true) ] public NoYes parmShowDetails(NoYes _showDetails = showDetails) { showDetails = _showDetails; return showDetails; } /// /// Validates the parameters. /// /// /// true if successful; otherwise, false. /// public boolean validate() { boolean isValid = true; if(!this.parmDateFrom()) { error("Date from is mandatory"); isValid = false; } if(this.parmDateFrom() && this.parmDateTo()) { // Check whether FromDate is greater than ToDate or not if (this.parmDateFrom() > this.parmDateTo()) { error("@SYS91020"); isValid = false; } } return isValid; }}Controller class:
class VKSalesQuotationDailyController extends SrsReportRunController{ public static VKSalesQuotationDailyController construct() { return new VKSalesQuotationDailyController(); } public static void main(Args _args) { VKSalesQuotationDailyController salesQuotationDailyController = VKSalesQuotationDailyController::construct(); salesQuotationDailyController.parmReportName(ssrsReportStr(VKSalesQuotationDailyBookingR, Report)); salesQuotationDailyController.parmArgs(_args); salesQuotationDailyController.parmDialogCaption("Sales quotation daily bookings"); salesQuotationDailyController.startOperation(); } protected void prePromptModifyContract() { VKSalesQuotationDailyContract contract = this.parmReportContract().parmRdpContract(); // Set the report design name. this.parmReportContract().parmReportName(ssrsReportStr(VKSalesQuotationDailyBookingR, Report)); } /// /// Modifies the contract before the report is run. /// protected void preRunModifyContract() { VKSalesQuotationDailyContract contract = this.parmReportContract().parmRdpContract(); date fromDate = contract.parmDateFrom(); date toDate = contract.parmDateTo(); Query query = this.getFirstQuery(); // Modify the query contract based on fromDate & toDate. SrsReportHelper::addFromAndToDateRangeToQuery(query, fromDate, toDate, tableNum(SalesQuotationTable), fieldNum(SalesQuotationTable, CreatedDateTime)); }}
Data provider class:
[ SRSReportParameterAttribute(classStr(VKSalesQuotationDailyContract))]class VKSalesQuotationDailyDP extends SRSReportDataProviderPreProcessTempDB{ VKSalesQuotationDailyHeaderFooter salesQuotationDailyHeaderFooter; VKSalesQuotationDailyContract contract; [SRSReportDataSetAttribute(tablestr(VKSalesQuotationDailyHeaderFooter))] public VKSalesQuotationDailyHeaderFooter getSalesQuotationDailyHeaderFooter() { select salesQuotationDailyHeaderFooter; return salesQuotationDailyHeaderFooter; } /// /// Process report data. /// public void processReport() { contract = this.parmDataContract() as VKSalesQuotationDailyContract; // Populate report header / footer information this.populateSalesQuotationDailyHeaderFooter(); } protected void populateSalesQuotationDailyHeaderFooter() { CompanyInfo companyInfo = CompanyInfo::find(); salesQuotationDailyHeaderFooter.CompanyName = companyInfo.name(); salesQuotationDailyHeaderFooter.DateFrom = contract.parmDateFrom(); salesQuotationDailyHeaderFooter.DateTo = contract.parmDateTo(); salesQuotationDailyHeaderFooter.ShowDetails = contract.parmShowDetails(); salesQuotationDailyHeaderFooter.insert(); }}Output menu item:
Temporary table (VKSalesQuotationDailyHeaderFooter) should be Table Type = TempDB
Create/Prepare a Query in AOT
Add the query as dataset to SSRS report. Set Dynamic Filters property to True in properties of Query dataset:

If changing the property to "True" you are facing with "The number of defined parameters is not equal to the number of cell definitions in the parameter panel." error, you will have to fix it manually (follow the link).
Add data provider dataset tp the report:

Report dialog:


Источник: http://daxonline.org/1715-rpd-and-qu...x-classes.html