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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 04.10.2015, 07:04   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
How to create SSRS report with multiple independent groupings
Источник: http://alexvoy.blogspot.com/2015/10/...-multiple.html
==============

Let's say we need to print for selected sales orders all their items with sales prices and barcodes. It means our report must look like this.



One page by SalesId, some kind of a card with all items presented in the related SalesLine table. Then for each ItemId we group all its sales prices, first, and all its barcodes, second.

As suggested by Best Practice, we can create one flat temporary table (regular in my case just to ease debugging) to merge all data into one data source for our report.



Additional GroupType field is populated with different values for each table: SalesLine, Barcode, or SalesLine (could be done as enum). They will be used in report design for filtering tablix elements.

As to design we would need the main TablixSalesId with grouping by SalesId and breaking page for each instance.



Then nested TablixItemId grouped by ItemId.



Now we need to add two new ones - TablixBarcode and TablixSalesPrice without any additional grouping but with filters as follows.







This approach with adding "artificial" field to a flat table let to distinguish data and easily group and filter them.




Feel free to download the full project here.

This is the code of two principal methods of Report data provider class.


[SysEntryPointAttribute(false)]
public void processReport()
{
QueryRun qr;
SalesTable salesTable;

tmpItemSalesPriceAndBarcode.setConnection(this.parmUserConnection());
barcode = Barcode::construct(BarcodeType::EAN128);
// Run the query
qr = new QueryRun(this.parmQuery());
while(qr.next())
{
if(qr.changed(tableNum(SalesTable)))
{
salesTable = qr.get(tableNum(SalesTable));
this.settmpItemSalesPriceAndBarcode(salesTable);
}
}
}

private void settmpItemSalesPriceAndBarcode(SalesTable _salesTable)
{
#define.TypeSalesLine('SalesLine')
#define.TypeBarcode('Barcode')
#define.TypePurchPrice('SalesPrice')

SalesLine salesLine;
PriceDiscTable priceDiscTable;
InventTable inventTable;
InventItemBarcode itemBarcode;
BarCodeString barCodeString;

if(_salesTable.SalesId)
{
// all sales line items
while select ItemId from SalesLine
group by ItemId
where salesLine.SalesId == _salesTable.SalesId
{
tmpItemSalesPriceAndBarcode.clear();
tmpItemSalesPriceAndBarcode.SalesId = _salesTable.SalesId;
tmpItemSalesPriceAndBarcode.ItemId = salesLine.ItemId;
tmpItemSalesPriceAndBarcode.GroupType = #TypeSalesLine;
tmpItemSalesPriceAndBarcode.insert();
// now for each item
// barcodes
while select ItemBarcode, RetailVariantId from itemBarcode
where itemBarcode.ItemId == salesLine.ItemId
{
tmpItemSalesPriceAndBarcode.clear();
tmpItemSalesPriceAndBarcode.SalesId = _salesTable.SalesId;
tmpItemSalesPriceAndBarcode.ItemId = salesLine.ItemId;
tmpItemSalesPriceAndBarcode.GroupType = #TypeBarcode;
tmpItemSalesPriceAndBarcode.ItemBarcode = barcode.encodeString(itemBarcode.ItemBarcode);
tmpItemSalesPriceAndBarcode.RetailVariantId = itemBarcode.RetailVariantId;
tmpItemSalesPriceAndBarcode.insert();
}

// purch prices
while select Amount, FromDate, ToDate, UnitId, Currency from priceDiscTable
where priceDiscTable.ItemRelation == salesLine.ItemId
&& priceDiscTable.ItemCode == TableGroupAll::Table
&& priceDiscTable.Module == ModuleInventCustVend::Cust
{
tmpItemSalesPriceAndBarcode.clear();
tmpItemSalesPriceAndBarcode.SalesId = _salesTable.SalesId;
tmpItemSalesPriceAndBarcode.ItemId = salesLine.ItemId;
tmpItemSalesPriceAndBarcode.GroupType = #TypePurchPrice;
tmpItemSalesPriceAndBarcode.Amount = priceDiscTable.Amount;
tmpItemSalesPriceAndBarcode.ToDate = priceDiscTable.ToDate;
tmpItemSalesPriceAndBarcode.FromDate = priceDiscTable.FromDate;
tmpItemSalesPriceAndBarcode.UnitId = priceDiscTable.UnitId;
tmpItemSalesPriceAndBarcode.Currency = priceDiscTable.Currency;
tmpItemSalesPriceAndBarcode.insert();
}
}
}
}


Источник: http://alexvoy.blogspot.com/2015/10/...-multiple.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
How to run a report for multiple records from a grid Blog bot DAX Blogs 0 04.10.2015 07:04
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
ax-erp: Report Data provider [RDP] as data source type in data set – SSRS reports [Dynamics ax 2012] Blog bot DAX Blogs 0 18.07.2012 12:11
axaptacorner: How to create permission matrix for SSRS Report Blog bot DAX Blogs 0 26.06.2012 23:12
emeadaxsupport: New Content for Microsoft Dynamics AX 2012 : October 2011 Blog bot DAX Blogs 0 27.10.2011 17:11

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 05:38.