AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 19.01.2021, 16:12   #1  
Blog bot is offline
Blog bot
Участник
 
23,915 / 805 (74) +++++++
Регистрация: 28.10.2006
a33ik: RPD based SSRS report with Query (DateFrom, DateTo), AX classes
Источник: http://daxonline.org/1713-rpd-based-...x-classes.html
==============

Contract class:
[DataContractAttribute]class VKSalesQuotationDailyContract 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(VKSalesQuotationDailyBooking, 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(VKSalesQuotationDailyBooking, Report)); }}Data provider class:
[ // https://docs.microsoft.com/en-us/dyn...ss-in-a-report SRSReportQueryAttribute(queryStr(VKSalesQuotation)), SRSReportParameterAttribute(classstr(VKSalesQuotationDailyContract))]class VKSalesQuotationDailyDP extends SRSReportDataProviderPreProcessTempDB{ VKSalesQuotationDailyHeaderFooter salesQuotationDailyHeaderFooter; VKSalesQuotationDaily salesQuotationDaily; VKSalesQuotationDailyContract contract; [SRSReportDataSetAttribute(tablestr(VKSalesQuotationDailyHeaderFooter))] public VKSalesQuotationDailyHeaderFooter getSalesQuotationDailyHeaderFooter() { select salesQuotationDailyHeaderFooter; return salesQuotationDailyHeaderFooter; } [SRSReportDataSetAttribute(tablestr(VKSalesQuotationDaily))] public VKSalesQuotationDaily getSalesQuotationDaily() { select salesQuotationDaily; return salesQuotationDaily; } /// /// Process report data. /// public void processReport() { contract = this.parmDataContract() as VKSalesQuotationDailyContract; // Populate report header / footer information this.populateSalesQuotationDailyHeaderFooter(); // Populate data this.populateSalesQuotationDailyBookingInformation(); } 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(); } protected void populateSalesQuotationDailyBookingInformation() { Query q = this.prepareQuery(); QueryRun qr; SalesQuotationTable salesQuotationTable; SalesQuotationLine salesQuotationLine; boolean showDetails = contract.parmShowDetails() ? true : false; qr = new QueryRun(q); while (qr.next()) { salesQuotationTable = qr.get(tableNum(SalesQuotationTable)); salesQuotationLine = qr.get(tableNum(SalesQuotationLine)); salesQuotationDaily.CustAccount = salesQuotationTable.CustAccount; salesQuotationDaily.CustName = salesQuotationTable.customerName(); salesQuotationDaily.CustPurpose = salesQuotationTable.VKCustPurpose; salesQuotationDaily.WorkerSalesTaker= HcmWorker::find(salesQuotationTable.WorkerSalesTaker).PersonnelNumber; salesQuotationDaily.SalesAmount = salesQuotationLine.LineAmount; if (showDetails) { salesQuotationDaily.ItemName = salesQuotationLine.itemName(); salesQuotationDaily.SalesQty = salesQuotationLine.SalesQty; } salesQuotationDaily.insert(); } } protected void insertSalesQuotationDaily(SalesAmount _salesAmount) { salesQuotationDaily.SalesAmount = _salesAmount; salesQuotationDaily.insert(); } protected Query prepareQuery() { Query q = this.parmQuery(); if (contract.parmDateFrom()) { SrsReportHelper::addFromAndToDateRangeToQuery( q, contract.parmDateFrom(), contract.parmDateTo(), tableNum(SalesQuotationTable), fieldNum(SalesQuotationTable, CreatedDateTime)); } return q; }}Output menu item:
Temporary table (VKSalesQuotationDaily. VKSalesQuotationDailyHeaderFooter) should be Table Type = TempDB

Creating datasets at the SSRS report set Dynamic Filters property to True on all datasets from same data provider.



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).
Report dialog:






Источник: http://daxonline.org/1713-rpd-based-...x-classes.html
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
bojensen: Simple SSRS report example by using Ax-Query and Ranges Blog bot DAX Blogs 0 20.03.2013 01:11
bojensen: How to Set the Query Range on a SSRS Report | Amir’s Microsoft Dynamics AX space Blog bot DAX Blogs 0 18.03.2013 17:11
dax-lessons: Save SSRS report to pdf that uses Controller classes [Dynamics AX 2012] Blog bot DAX Blogs 0 12.05.2012 01:11
saveenr: Dynamics AX 2012: A Preview of SSRS Report Development (Part 1) Blog bot DAX Blogs 0 06.02.2011 00:11
dynamics-ax: Expert SSRS with AX Tip from Michael Stashwick Blog bot DAX Blogs 0 14.01.2011 05:18
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 18:11.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.