Академический Документы
Профессиональный Документы
Культура Документы
Introduction
SQL Server Reporting Services (SSRS) is the primary reporting platform for Microsoft Dynamics AX 2012. The default, out-of-the-box reports that are provided with Microsoft Dynamics AX run on the Reporting Services platform. They give users better looking reports, more export formats, and a more capable report designer. The goals for this transition include following: Use the Microsoft technology stack. Keep business logic in Microsoft Dynamics AX. Transition for X++ and C# developers to the new reporting architecture is simplified.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-1
Reporting Architecture
The report development pattern in used for SSRS reports Microsoft Dynamics AX 2012 uses the Model-View-Controller (MVC) design pattern variation. This pattern allows many client types to call Microsoft Dynamics AX 2012 Reporting Services reports including: Microsoft Dynamics AX clients, Enterprise Portal, and Batch Job. This also means that Reporting Services can be replaced by a different application for rendering reports. The following figure illustrates the SSRS architecture in Microsoft Dynamics AX 2012.
12-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Upgrade Consideration
Reports and cubes are not upgraded to Microsoft Dynamics AX 2012. The X++ reporting framework is being deprecated in Microsoft Dynamics AX 2012. Reports that are based on the X++ reporting framework and existing SQL Server Reporting Services reports will be copied to the Microsoft Dynamics AX 2012 system. However, they will not be upgraded. It is recommended to use a SQL Server Reporting Services report that is provided with Microsoft Dynamics AX 2012 as a template and customize it to meet your needs.
Configuration
You can use the Reporting services framework to modify the queries used to retrieve data for reports. This means that you can now use SQL Reporting Services capabilities to filter, group, and sort data in reports.
Auto-Reports
With Microsoft Dynamics AX 2012, you can use the Auto-report wizard to create custom, ad hoc reports that are based on the SQL Server Reporting Services framework. To start the Auto-report wizard, click the Print icon on a form.
Batch Support
SQL Server Reporting Services reports in Microsoft Dynamics AX 2012 are now integrated with the Microsoft Dynamics AX batch framework. You can schedule a long-running report to print during off-peak hours and schedule a report to print on a recurring basis.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-3
12-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Report Datasets
A report dataset identifies the data from a data source that displays in a report. When you define a dataset, you must specify the data source and the means used to retrieve the data, such as a query or data method. The following table describes the options for retrieving data for a report. Data source Dynamics AX Option Queries that are defined in the AOT SQL OLAP Report Data Provider classes that are defined in the AOT Data methods that are defined within a reporting project in Microsoft Visual Studio TSQL query Stored procedure Dynamics AX OLAP
If your report uses the Dynamics AX data source and a query that is defined in the AOT in Microsoft Dynamics AX, you must be especially careful when updating the query in the AOT. For example, if you remove a field in the query and the field displays in the report, the report will display an empty column for the field. Whenever you make updates to a query, consider how those updates can affect your reports. Updates to a query can also require updates to your reports. A report can have multiple datasets. A dataset can be used by one or more data regions in a report.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-5
Use when your business logic is contained in C# code. Your code must return a dataset.
12-6
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
NOTE: A query should be considered before you use a Report Data Provider class. AX Enum Provider Use when the report parameter is an Enum type. These parameters expose Enum types on a report in a friendly drop-down list. You can create a range on a query to expose an enum parameter in the Microsoft Dynamics AX client. However, if you want the report to be run from the Enterprise Portal, you must use an AX Enum Provider to define the parameter.
A controller class runs the report by creating the UI, calling SQL Server Reporting Services, and preprocessing the parameters for the report. If any of the following scenarios occur, you must extend the SrsReportRunController class to create a custom controller for the report. Report requires input data to be preprocessed. Report requires input data to be manipulated or modified. Multiple reports should be run from the same dialog box.
NOTE: Reports that use a controller class must take care of the parameters when the report is used on the Enterprise Portal.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-7
Development Actions
The following demonstration shows how to create a query bound report that exposes Customer Transaction data. The steps that are involved include create a Microsoft Dynamics AX query, add field data to the query, create a new report model in Visual Studio, create a report dataset, create a report design and apply style templates.
12-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-9
12-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-11
12-12
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-13
12-14
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-15
12-16
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-17
12-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-19
12-20
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Challenge Yourself!
Use the information that is provided to create a query bound report that exposes vendor transaction data. Create the new report in Visual Studio and add sorting and grouping by vendor account to the report. Then add a report filter for the account number, and add a dynamic parameter for the vendor account. When you are finished, save and deploy the report and add a menu item to the Accounts Payable module to view the report on the menu.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-21
12-22
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-23
12-24
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
17. Optional: In the Model Editor, right-click the AutoDesign1 node, and then click Preview to view the new style settings for the report. 18. Optional: Close the Preview window. 19. Save the report.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-25
Save the Microsoft Dynamics AX Menu Item. Right-click the VendTransList_WS1 menu item and select Open. In the AOT, expand Menu Items node and select the Output node. Right click the Output node, and then select Open New Window. In the original AOT window, expand Menus. Expand AccountsPayable > Reports > Transactions > Vendor. Select the VendTrans_W1 Menu Item in the new AOT window that was opened in step 4. 14. Drag the Menu Item into the Menu. 15. Save the Menu.
12-26
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Model-View-Controller
Model-view-controller (MVC) is a pattern used to isolate business logic from the user interface. By using MVC, the model represents the information (the data) of the application and the business rules used to manipulate the data, the view corresponds to elements of the user interface such as text, checkbox items, and so on, and the controller manages details involving the communication between the model and view. The controller handles user actions such as keystrokes and mouse movements and pipes them into the model or view as required. Model: Responsible for retrieving data and for business logic, this can included queries, data methods, or other classes that are designed to retrieve data. View: Responsible for the User Interface, this can also be thought of as the design for the report. Controller: Orchestrates the flow between Model and View
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-27
The Creating Basic Reports from a Query topic reviewed a simple example of a report where all of these elements existed. However, the design and the control of the report were not modified. Instead the base classes for the SSRS reporting framework in Microsoft Dynamics AX 2012 rendered the report dialog and handled the logic that was required to run the report. The steps used to create a report data provider that will deliver data to a report follow.
12-28
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
TIP: Before you begin development for a new report visualize the layout of the report using by Microsoft Office Excel or draw the report design on a piece of paper.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-29
12-30
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-31
5. Create a new method in the class by clicking the new icon. 6. Enter the following code sample for the Parent node parameter.
/// <summary> /// Gets or sets the value of the datacontract parameter ParentNode. /// </summary> /// <param name="_parentNode"> /// The new value of the datacontract parameter ParentNode; required. /// </param> /// <returns> /// The current value of datacontract parameter ParentNode /// </returns> [ DataMemberAttribute('ParentNode'), SysOperationLabelAttribute(literalstr("@SYS58556")) ] public Name parmParentNode(Name _parentNode = parentNode ) { parentNode = _parentNode; return parentNode; }
7. Create a new method in the class by clicking the new icon. 8. Enter the following code sample for the Property value parameter.
12-32
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-33
12-34
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
To create a precision design to match desired layout, follow these steps: 1. In the Model Editor, select the AOTObjectsDS node and drag it onto the Designs node. An auto design named AutoDesign1 is created for the report. 2. Right-click the AutoDesign1 node, and then click Preview. 3. Set the LayoutTemplate & TableStyleTemplate properties to define the report visual settings. 4. Group the report dataset on the =Fields!Property.Value. 5. Right-click the AutoDesign1 node, and then click Create Precision Design. 6. Right-click the PrecisionDesign1 node, then click Rename, and set the name to Report.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-35
12-36
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
//Create an instance of the report //Pass in the report that you want to run by using the format // '<ReportName>.<DesignName>' reportRun = new SrsReportRunImpl('CustBaseData.Report'); // Run the report. reportRun.runReport();
NOTE: This example runs a simple report that does not have a modified contract. TIP: In a more complex example where the report uses a data contract class, additional code will be required. For an example of how to implement this, refer to the EPSendDocument class makeDocument() method. This class is designed to print a different report based on the record that is passed in.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-37
12-38
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-39
12-40
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-41
12-42
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
TIP: Other methods are available to hide various objects within the reporting framework. For example, if you want to hide the report dialog box you can call the showDialog() method and pass in false to set the value. For a complete list of methods and their functionality, refer to the developer help on MSDN.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-43
TIP: To use the code sample provided, create a new SSRS report in Visual Studio. Next, create a data method with the code sample provided, and then create a new Data Set. Make sure that you set the Data Source Type property to Business Logic, and then in the Query property select the RetrieveItemData method that you created. Then you must design the report. When you are finished you can preview the report. Data methods can have parameters. A parameter for a data method can be any .NET type. When a data method is used in a dataset, a report parameter is automatically generated for each parameter in the data method. Report parameters display below the Parameters node in the Model Editor. The following scenarios are not supported in data methods. Overloading data methods is not supported. You can have only one data method of a particular name inside a model. If you overload a data method, you will receive an error stating that multiple data methods with the specified name exist, and you will be unable to use the data method within the report. Sharing data methods between reporting projects. Accessing Microsoft Dynamics AX queries by using data. Use a report data provider class to access a Microsoft Dynamics AX query in a report.
12-44
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-45
Print Management
Print management gives users control of print settings for selected Microsoft Dynamics AX reports. Print settings include the number of copies, the printer destination, and the multilanguage text that can be included on the report. Some additional print management features that you can use include the following. Modify the print settings of a report that is based on the contents of the data being printed. For example, send sales orders greater than 1000 U.S. dollars (USD) to Printer A and sales orders greater than 10,000 USD to Printer B. Specify print settings at various levels of the application. For example, module-level print settings apply to all documents in a given module, whereas customer-level print settings only apply to specific customers and transaction-level print settings apply only to specific transactions. Override or add to the settings from higher levels in the application. For example, module-level settings can be overridden at the customer or transaction level if not desirable. Moreover, additional settings can be added to the existing settings for similar reasons.
12-46
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Defining Metadata
Print management metadata is defined completely in code and originates from four main classes or concepts: PrintMgmtDocType (documents), PrintMgmtNode (nodes), PrintMgmtHierarchy (hierarchies), and PrintMgmtReportFormat (formats). A document is the document or report to which specific print management settings apply. Documents are the core of print management because all settings are defined for documents of a particular type. When users set up this information, it is used when that document is printed. The documents in the print management system are defined in the PrintMgmtDocType class and are always related to specific nodes in print management. A node is a particular level of defaulting in a hierarchy. For example, in the Accounts Receivable module print management settings can exist at the Sales Order Transaction level, the Customer level and the Module level. Each of these levels is considered a node and each node in print management must derive from the abstract PrintMgmtNode class. While nodes define the level at which print management settings can exist, they have no order by themselves which is where hierarchies help.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-47
The Accounts Receivable node represents the module level settings and all documents present in the module apply at this level. The Customer node represents settings that apply to specific customers and all documents present in the module apply. At the lowest level the nodes represent transaction level settings and only certain documents apply to each specific transaction. Sometimes to integrate with print management, you might have to modify existing nodes or hierarchies to meet the needs of the documents that you want to print. You might also be required to create new nodes, hierarchies or documents to accomplish the same goal. The following sections outline the steps that are required to accomplish these common integration tasks.
12-48
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-49
12-50
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3. Create a new class that derives from the PrintMgmtNode class. Make sure that you reference the existing PrintMgmtNode derivatives for examples. The class should be prefixed with 'PrintMgmtNode_' and should follow the naming pattern of the existing nodes. If the node is tied to a particular table, the table name should follow the prefix such as PrintMgmtNode_CustTable, for example. o Implement the getDisplayCaptionImplementation method. o o This method controls the caption that will appear for the instance of the node in the Print Management window. Return the appropriate label for Module level settings. Refer to existing examples in PrintMgmtNode_Purch or PrintMgmtNode_Sales. Return strfmt("@SYS108943", _tableBuffer.caption()) for account level settings. Refer to the existing example in PrintMgmtNode_CustTable or PrintMgmtNode_VendTable. Return strfmt("@SYS108944", _tableBuffer.caption()) for transaction level settings. Refer to existing examples in PrintMgmtNode_SalesTable or PrintMgmtNode_PurchTable. Customize as necessary for unique situations.
o o
Implement the getDocumentTypes method. o o Return a list of document types the node supports. The document types should be wrapped in configuration key checks so that they are only loaded if the configuration key is enabled. For example, isConfigurationkeyEnabled(configurationkeynum(Logist icsBasic)).
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-51
Implement the getNodeType method. o Return the appropriate PrintMgmtNodeType enumeration value.
Implement the getReferenceTableId method. o Return the table to which the node will be related. For example, if a node is tied to specific customers that you would return tablenum(CustTable). If the node is not related to a specific table, return the value of 0. Module level settings are examples of nodes that are not tied to specific tables.
4. Modify the PrintMgmtNode::construct method. Add a case statement to construct your new node. 5. Create appropriate unit tests. o o The name of the test class should be identical to the node followed by the postfix 'Test'. About the contents of the tests, follow the example of existing node tests that resemble your node type. For example, modulelevel, account level, transaction level nodes, or other. To add data, follow the existing examples in the PrintMgmtTestSuite class. o Add a macro that defines the ID of the table in the classDeclaration. o Add a new method that retrieves the table following the existing pattern. For example, getSalesTable, getCustInvoiceTable, and so on.
12-52
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6. If the node relates to a table, update the appropriate relations and cascading deletes. o Create a relation on the PrintMgmtDocInstance table to the table that you are referencing. For example, PrintMgmtDocInstance > SalesTable. Add a cascading delete action on the table that you are referencing to the PrintMgmtDocInstance table. For example, SalesTable > PrintMgmtDocInstance.
7. Add the node to the appropriate hierarchy. See the Create or Modify Hierarchies section for the steps that are required to perform this action. 8. Add the node to the PrintMgmt shared project.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-53
3. Modify the PrintMgmtHierarchy::construct method. Add a case statement to construct your new hierarchy. 4. Create appropriate unit tests. o o o The name of the test class should be identical to the hierarchy followed by the postfix 'Test'. About the contents of the tests, follow the example of existing hierarchy tests. To add data, follow the existing examples in the PrintMgmtTestSuite class. o
Add a macro that defines the ID of the table in the classDeclaration. o Add a new method that retrieves the table following the existing pattern. For example, getSalesTable or getCustInvoiceTable. o Create the data in the setUpReferenceData method and make sure that you trackInsertedRows for the table that you add. As soon as you are finished, add the new test to the PrintMgmtTestSuite by adding the appropriate entry in the new method. 5. If you are modifying an existing hierarchy, make sure that you update the appropriate hierarchy tests. Modify the testIsValidNodeType method. Update the count because the number of nodes added will have changed. 6. Add the hierarchy to the PrintMgmt shared project.
12-54
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Summary
This chapter introduced the features of SSRS and demonstrated how to create a simple report by using a query and an auto-design. Additionally, the chapter showed how you can use the report data provider framework to deliver business logic to a report in more complex business scenarios. The MVC is a pattern used to separate the data (Model) from the user interface (View) and the business logic (Controller) is used to communicate between the Model and the View. You can implement this framework by decorating your classes together with attributes such as the DataContractAttribute and the DataMemberAttribute. You can use the SRSReportRun framework to control how the printing and output of a report will be handled. You can also use X++ to set parameter values when running a report. In addition to the query framework and the report data provider framework, you can use business logic in Visual Studio to retrieve the data for a report. To use business logic in a report you must create a data method that includes the DataMethhod() attribute. A data method can also be used within report expressions to perform data manipulations or calculations for fields that display in the report. Developers can implement print management for selected Microsoft Dynamics AX reports. This gives users control of print settings. A developer must create or modify the document, node, and hierarchy for each report that you want to enable print management for.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-55
12-56
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-57
2.
3.
12-58
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Solutions
Test Your Knowledge
1. Put the following steps in the correct order to create a new SSRS report from a Microsoft Dynamics AX query: Step: 6 3 2 1 5 4 : Apply style templates. : Create a new report model in Visual Studio. : Add field data to the query. : Create a new query in the AOT. : Create a report design. : Create a report dataset.
2. Which of the following is not a feature of reporting in Microsoft Dynamics AX 2012? ( ) Deployment by using PowerShell scripts. ( ) Support to submit a report to the batch processor. () MorphX report designer in the Application Object Tree. ( ) Support to use labels in a report design to provide support for multiple languages for the same report. 3. What must you create to store the data when a report data provider class is used for the data set? ( ) A persisted table in SQL () An in-memory temporary table in the AOT ( ) A persisted table in the AOT ( ) A temporary table in SQL 4. Which of the following options is not a class that is used for implementing print management on a new report? ( ) PrintMgmtDocType ( ) PrintMgmtHierarchy () PrintMgmtReport ( ) PrintMgmtNode
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
12-59
6. Which of the following is not a step in the process for saving and deploying a report project? ( ) Rebuild the solution ( ) Save the report to the AOT () Import the report into the AOT ( ) Deploy the report
12-60
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement