09.09.2012, 20:15 | #1 |
Участник
|
sumitsaxfactor: Building a simple report – Using Report Data Provider
Источник: http://sumitsaxfactor.wordpress.com/...data-provider/
============== In my previous post, I explained how we can build a simple report using just the AOT queries. Now what if we have some logic that needs to be implemented and cannot be achieved using AOT queries? This is where Report Data Providers plays a significant roles. Let us take the same example of displaying the Customer Id, Name and Balance that was used in post “Build and Deploy Simple Report–Queries”. We can have this report using Report Data Providers as well. For this, we will keep the query and create three more artifacts, RDP, Report and a new Output menu item. First we create a Report Data Provider class named “SKL_SampleReportDP”. Do the following: To create an RDP for a report, we also need a temporary table (if it is Base Provider) or a permanent table (if it is pre process provider). For this sample, we will use CustTmpAccountSum table that is present in base product. Here are the class methods /// /// The SKL_SampleReportDP class is the report data provider class for the /// SKL_SampleSimpleReportQuery report. /// /// /// This is a sample class. Author: Sumit Loya /// [ SRSReportQueryAttribute (querystr(SKL_SampleCustomer))] class SKL_SampleReportDP extends SRSReportDataProviderBase { CustTmpAccountSum tmpAccountSum; } The class declaration contains one attribute “SRSReportQueryAttribute”. This attribute specifies the query that will be used for this report. In case no query is required, this attribute can be removed. There is one other attribute that can be specified on the RDP class and that is SRSReportParameterAttribute. This attribute defines the contract class that will be used to display report parameters. processReport method The processReport method is the entry point for calculating the report data for dataset. Here is the method for our sample class [SysEntryPointAttribute(false)] publicvoid processReport() { this.insertTmpAccountSum(); } insertTmpAccountSum method This is a private method that uses the report query to insert data into the temporary table /// /// This method processes the report query and inserts data into the CustTmpAccountSum temporary table /// privatevoid insertTmpAccountSum() { QueryRun queryRun = new QueryRun(this.parmQuery()); CustTable custTable; while (queryRun.next()) { custTable = queryRun.get(tableNum(custTable)); tmpAccountSum.AccountNum = custTable.AccountNum; tmpAccountSum.Txt = custTable.name(); tmpAccountSum.Balance01 = custTable.openBalanceMST(); tmpAccountSum.insert(); } } getCustTmpAccountSum method This method is mandatory as it returns the table buffer that contains the processed report data. The Dataset uses this buffer to bind the table to the dataset. /// /// This method returns the table buffer that contains processed data /// [SRSReportDataSetAttribute(tableStr(CustTmpAccountSum))] public CustTmpAccountSum getCustTmpAccountSum() { select * from tmpAccountSum; return tmpAccountSum; } After creating the class, go ahead and add a new report the existing report model.
Now using menu item open and run report. You will notice the same dialog The report looks like as shown below: Источник: http://sumitsaxfactor.wordpress.com/...data-provider/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|