Sunday, July 29, 2018

Difference between SRSReportDataProviderBase,SrsReportDataProviderPreProcess and SrsReportDataProviderPreProcessTempDB


After searching for detail explanation on the SRSReportDataProvide, found some good explanation on these topics, sharing with you the same data and their link in the end.

Why does converting a report to pre-processing help to resolve timeout issues?

Sometimes in AX we need to create reports that exceed the default run-time limits defined in AX (default is 10minutes) because of the amount of data we are either calculating or returning. As discussed in one of my other posts (AX SSRS Report times out after 10 minutes) one of the ways to overcome this is to change the config files of the client/ssrs server but another way to overcome this limit and improve the speed in which a report can be ran is changing your data provider to extend the class 'SrsReportDataProviderPreProcess' instead of the regular type of 'SRSReportDataProviderBase'

In order to switch from the regular process we need to make the following changes:

  1. On the table that is returned as a dataset to the report make the following changes
    1. Created by - Yes
    2. CreatedTransactionId - Yes
    3. TableType - Regular
  2. Change the DP class so it extends SrsReportDataProviderPreProcess
  3. Within the DP class.processReport() method add the following code reportData.setConnection(this.parmUserConnection()); where reportData is the table that is returned as a dataset within your report
  4. Execute a incremental cil
  5. Open the SSRS report and hit refresh on the dataset. At this point you should see the field 'createdTransactionId' added to the available field.
  6. Deploy report
  7. Security Note: For your security object it is good to note that when using this preprocessing method you need to add the DPClass.processReport() method to the Server methods node in the privilege associated with the report


Without pre-processing the report is executed in these steps:

With pre-processing the steps are executed in a different order:

The report server execution time is the time between the two steps:

This explains why in case of reports with pre-processing it takes less time for the report server to render the report and why some timeouts will not be hit. (In many reports, it is actually the preparation of the data by AX that is most time consuming.)
This also explains why converting a report to pre-processing does not necessarily mean that the report will execute faster in overall. Particularly it will not, if the underlying tables are SQL tables. In these cases, the steps are only swapped – nothing else. The overall execution time of the report as perceived by the user is the sum of all three steps and this sum is the same in either approaches. On the other hand, reports that use InMemory temporary tables may execute faster after the conversion because pre-processing is implemented with SQL tables. InMemory temporary tables with large amounts of data may need to be paged to the file system and that may influence the data retrieval time. Moving these data to SQL tables may improve the report’s overall execution time.
Keeping in mind that only reports that use the Report Data Provider class can be converted to pre-processing (and this in fact does not necessarily lead to reports executing faster in overall), it is often required to increase the timeouts to enable a long running report to complete successfully. In order to reduce the trial and error phase to minimum, it makes sense to configure very generous timeouts for the start just to go sure that a report can be executed successfully. There is basically nothing that speaks against setting this timeout initially to 24 hours, for example. If the report was executed successfully we can take the exact time from the corresponding RS log file or RS Execution Log (they are collected by default) and reduce the timeouts to a value that ensures a successful execution of the affected report.
Configuring the timeout to a value higher than 12 hours, it is also recommended to increase the RecycleTime in the rsreportserver.config file accordingly. This value is 720 minutes per default (12 hours). We saw that when the application domain got recycled while a long running report was executed that it led to an error in most cases. Taking into account that all thresholds/timeouts will be reset at the Reporting Services service startup, it is recommended for testing to restart the service before starting a long running report so all counters get initiated at the same time.
Furthermore, in AX 2012 R2, it is required that the kernel build version is 6.2.1000.6578 or higher, in AX 2012 R3, 6.3.164.2421 or higher (KB 2936794). If it is not, the latest kernel hotfix available to date should be installed. Installing the latest kernel hotfix is recommended in general. (See FAQ: Microsoft Dynamics AX Kernel Hotfixes if you have any questions regarding installing a kernel hotfix.)
  • If the report continues to fail, make sure that it does not fail due to a different reason (check RS log file/RS Execution Log).
  • If the report fails due to a timeout again, make sure if it fails at the value that has been just configured (check RS log file/RS Execution Log). If so, increase the timeouts.
  • If the report fails at a time before the chosen timeout, make sure that all settings were configured properly, none is missing or has an incorrect value by mistake.
  • If the report fails at a time before the chosen timeout and this time is always the same, check in the log how long it took exactly. 10 minutes? 30 minutes? Knowing it may help in identifying the setting that was missed when increasing. 10 minutes – could be a call to the AOS service, for example. 30 minutes – could be the default timeout on the report in the report server. Double check if the timeouts were configured properly following the post thoroughly.
  • If the report fails at a time before the chosen timeout, this time is always the same and none of the settings is missed, upload the attached report WaitFor2012.rdl to the report server (using Report Manager) and run it directly on the report server. This report is a pure SSRS report so there is no AX component involved. Enter the timeout currently configured and verify if the report fails again before this time and if this time is the same. If the report does fail, the reason could be an external (non-SSRS and non-AX) setting, in the network or ASP.NET, for example. If the report does not fail, this would indicate an issue in AX that may require investigation by AX support.

How To: Long Running Reports


Overview
One segment of reports worthy of its own classification are those operational reports that incur heavy processing time due to the number of objects involved in generating the report data set.  The vast majority of our out-of-box reports take on average <1 minute to render to screen depending upon the size of the data set.  However, there are many core reports that include business logic that iterates over transactions and inventory information which could easily exceed 10M table records in a production database.  As a result, these reports can take hours to complete the data set generation for the report.  A safe rule of thumb is to treat any report that takes >5 minutes in a non-production environment as a Long Running Report thus deserving special consideration when planning out the solution.  A few examples of long running reports include the Trial Balance Report, Customer Aging Report, and the Inventory Dimensions Statement Report.
What's important to understand as Report Developers is the fact that the SSRS Server utilizes service calls to communicate with the AOS when constructing the report data set.  As a result, the process of generating any report data set is subject to these service timeout limits.  By default, service timeouts are fixed at 10 minutes.  Further, any data set generation process exceeding this service timeout minute will fail to complete.  This article describes the extensions introduced as part of the Microsoft Dynamics AX 2012 R2 Release to facilitate the Long Running Reports to ensure that they are able to complete even if they exceed the 10 minute service timeout limits.
How do I migrate to Pre-process RDP?
  1. Modify RDP base class:  SRSReportDataProviderBase -> SRSReportDataProviderPreProcessTempDB 
  2. Update table type:  InMemory -> TempDB 
  3. Perform a full compile of IL 
  4. Restart the AOS 
  5. Introduce Controller class to run the report 
  6. Update Output Menu Item:  Report -> Controller class

Here's a quick YouTube video demonstrating the process of creating a pre-process RDP class for a Long Running Report:
[View:https://www.youtube.com/watch?v=6tdQtHV2WAc&list=UUfGIUxWmd1ZA11NB8FgVWpw]

Using SrsReportDataProviderPreProcessTempDB class

In Ax2012, we introduced class SrsReportDataProviderPreProcess class as the solution for long running SSRS reports that cause SSRS time out. The approach is to process data in Ax session before calling SSRS. The preprocessed data stored in a regular SQL table shared by all user sessions, only to be striped by session id. That approach creates a bottleneck in case of many concurrent user sessions. In R2, we introduced this new class to allow use of tempDB to carry report data across sessions, from Ax data processing session to SSRS data retrieval session. AOS kernel will not purge tempDB table when session end leaving it to application code to clean up the tempDB table. In case of report, this base class will take care of the clean up.
You should stop use the old SrsReportDataProviderPreProcess class but use the new base class instead for long running reports. You will see performance gain in case of multiple concurrent sessions on the same report.
Currently there are many OOB Ax2012 R3 reports already take advantage of this feature. You can check out how they are leverage the feature there. One typical example is TaxListDP class.
This R3 feature is implemented in the kernel. The usage is not limited to reporting. Attached is a sample project showing how this kernel feature is used in case of multi-threading in Ax: each thread creates its own instance of a temp table, inserts rows into the table, and passes the table name back to the main thread (crossing session boundary), where contents from each temp table is then merged into one DB table using set-based insert. At the end, the code must despose the temp tables. The code is for demonstraction only. A more practical application to leverage this feature is in batch processing.


Using Dynamic Set-based insert operation

In AX2012, set based insert operation is part of X++ syntax and is precompiled. That limits its use when filters are dynamic, i.e. taking from end user at run time.
In AX2012, R3 we implemented a DCR that allows constructing a set based insert where clause based on Query range on the fly. This feature allows much wider adoption of set based operation and greatly improve performance when applied.
A good coding example can be seen in TaxListDP.insertTaxListTaxTmpData. It is done using a new static method on Query object. Here is how it is used.
                Query::insert_recordset(taxListTaxTransTmp, insertRecordsetMap, query);
 the first parameter is the tempDB table and the second one is the mapping between the tempDB table fields and query fields. See detail in the AOT class source code. Here is the highlight of the row-based old code:
 
Without the DCR, we can’t change this code to set-based because query range is set by end users. Now, the highlight of the new high performance code is as follow:

Summary :
As the name suggests, SrsReportDataProviderPreProcess class is a special kind of Report Data Provider class that pre-process data.
in short, pre-processing is used when preparing the data would take so long that the printing would time out, therefore it first prepares the data and only then it calls the report.
SrsReportDataProviderPreProcess uses regular tables and therefore it needs to distinguish data for different runs of the same report, so it uses the transaction ID
Since SrsReportDataProviderPreProcessTempDB has been introduced, you should use it instead of SrsReportDataProviderPreProcess. TempDB don't need such the distinction over transaction ID, because there is a separate instance of the table for each run.


Friday, July 20, 2018

Important Tables and Classes in Inventory Module

Tables :-

EcoResProduct             --- This is a base table for the inherited tables that follow next.

EcoResProductMaster --- This table holds information on products that can have variants (color, size, and so on.). Within the application, these products are referred to as product masters.

EcoResDistinctProduct ---A distinct product is effectively a product that does not have variants (it is not associated with inventory dimensions color, size, and so on).

InventTable                     ---This table contains information about the released items.

InventItemGroup           ---This table contains information about item groups.

InventDimGroup            ---This table contains information about a dimension group.

InventTableModule        ---This table contains information about purchase, sales and inventory specific settings for items.

InventModelGroup        ---This table contains information about inventory model groups.

InventItemSalesSetup    ---This table contains default settings for items, such as site and warehouse. The values are related to sales settings.

InventItemPurchSetup  ---This table contains default settings for items, such as site and warehouse. The values are related to purchase settings.

InventItemInventSetup  ---This table contains default settings for items, such as site and warehouse. The values are related to inventory settings.

InventItemLocation        ---This table contains information about items and related warehouse, and counting settings. The settings can be made specific based on the items configuration and vary from warehouse to warehouse.

InventTransOrigin         ---This was a new table added in AX 2012 and is effectively used to
join InventTrans table to the origination (sales line, purchase lines, inventory adjustment, and so on) transaction line via the InventTransOrigin tables.

InventTransOrigin tables---There are multiple tables such as InventTransOrigin Salesline and InventTransOriginPurchLine, and they are fundamentally used to link the transaction origin document to an inventory transaction record.

InventSum                     ---This table contains information about the present and expected
on-hand stock of items. Expected on-hand stock is calculated by looking at the present on-hand values and adding whatever is on order (has been purchased but not arrived yet).

InventTrans table is what I like to call the parent table of all transactions. NO matter what is performed a record will be written to this table when posting occurs. The inventTrans table represents a flow of inventory transactions as data leaves and enters a company for example. If a product is ordered a status field will be set to ordered. If a item is transferred from one warehouse to another warehouse the status will then be set to transfer. The inventory transactions table is typically used for very detailed inventory reports.

InventDim table is table that holds the combinations of inventory attributes assigned to items at they progress through inventory transactions. For example, an item can be located in many different warehouse, at may different sites, and stored in certain locations. Imagine the number of combinations that can be associated with an items its endless. 

Below are the inventory dimensions AX uses to segregate items as they process through the system :

InventColorId       --- Item table contains information about colors.
InventSizeId          --- Item table contains information about item size.
ConfigId                --- table contains information about available configuration of the various items.
InventBatchId       --- table contains information about batches.
InventSerialId       --- table contains information about item serial numbers.
InventLocationId  --- table contains information about warehouses.
InventSiteId          --- table contains information about sites.
wmsLocationId     --- table contains information about locations.
wmsPalletId          --- table contains information about pallets.

CLASSES :-

InventSum The InventSum classes are used to find the on-hand information about a certain item at a certain date. The InventSum classes are not structured in a hierarchy as the previously mentioned classes.

InventOnHand class is used to find the current on-hand information.

InventMovement classes are used to validate and prepare data that will be used to generate inventory transactions. The super class in the hierarchy is the abstract class called InventMovement.

All the classes related to the inventMovement class will be prefixed with InvMov_
For example, InventMov_Sales is used to validate and prepare inventory with sales line transactions, or InventMov_Transfer, which is used when dealing with inventory transfer journals.

InventUpdate classes are used to insert and update inventory transactions. Whenever a transaction should be posted, the updateNow() method in the InventUpdate subclass will execute. The super class in the hierarchy is the InventUpdate class, and the other classes in the hierarchy are prefixed ‘InventUpd_’.

For example, InventUpd_Estimated is used whenever an item line is entered in the system that will most likely generate a physical transaction in the future. A good example can be a sales order line that has the on-order sales status. When a line like this is entered or generated in AX, the InventUpd_Estimated is triggered so that the inventory transactions will reflect that the item is on-order can is taken into consideration when the same item is ordered.

InventAdj :Whenever an adjustment to an inventory transaction takes place, the InventAdj classes are used. The adjustments typically occur when you are closing the inventory.



Source :- https://mfmujahidmim.wordpress.com/2015/12/17/microsoft-dynamics-ax-the-inventdim-table/

Thursday, July 5, 2018

Accenture IQ


  1. SSRS reports?
  2. DMF/DIXF?
  3. AIF?
  4. Workflow creation process?
  5. Upgradation process in AX?
  6. What are Storage Dimensions in AX?
  7. What is the use of PostLoad method in ax?
  8. How to delete multiple records in ax?
  9. Overriding values in the multiple layers, At runtime which will effects?
  10. Difference between Runbase and Runbase batch?
  11. How to Fetch current record in D365?
  12. How to take backup of all the elements of the USR layer?
  13. Difference between In memory and Temp DB?
  14. What is Assembly?
  15. What is a Model?
  16. Joins in AX?
  17. What is reference group?
  18. How to debug the runbase class?
  19. How to create ODBC connection?
  20. Where do we write the generate method?
  21. What is cluster index in ax?
  22. What is Replacement Key?
  23. What is Alternate Key?
  24. How to deploy the code in AX7 / D365?
  25. Rules of Extension in D365?
  26. How to debug the form in D365?
  27. How to export the code in D365?

Zerone Technology IQ


  1. Difference between Display and Edit Method?
  2. Can we filter the Grid or Page or Listpage using Display or Edit method?
  3. Overlaying VS Extension?
  4. When we should go for Overlaying and when for Extension?
  5. Sales and Purchase order tables and classes?
  6. Workflow creation process? What are the workflows available in standard?
  7. Upgration process?
  8. AIF?
  9. Query based Vs RDP report?
  10. Build vs Rebuild?
  11. Can we change sales Id properties of Sales Table in D365?
  12. Complex SSRS reports till date?
  13. Complex Task till date?

Microsoft IQ


  1. Table Properties 
  2. Table Group
  3. Table Relations
  4. How to display primary field in the form without adding the parent DS?
  5. Related field fixed
  6. Classes used in Sys operation framework
  7. Difference between SysOperation framework and RunbaseBatch?
  8. How to share table with multiple company?
  9. Important classes of DIXF?
  10. Sales order posting classes?
  11. Use of Map class in AX?
  12. Tables and classes used in SalesEditLineForm?
  13. How to deploy the code?
  14. How to move the code from Test to Production Environment?
  15. How to control the code when multiple developers are working?
  16. SSRS Reports :


  • Use of preprocess class
  • Table property required for preprocess 
  • How regular table drop the data

Monday, July 2, 2018

Difference between Build, Rebuild and Clean Solution


  • Build Solution     – Incremental build and compiles only the files that are changed.
                                          Compiles code files (DLL and EXE) which are changed.
  • Clean Solution    – Deletes all compiled, intermediate files (DLL and EXE file) .         
  • Rebuild Solution – Deletes all compiled files and compiles all irrespective of changes.                                  


Build Solution

This is the faster option to compile and run your solution in Visual Studio. When you opt for the BuildVisual Studio will perform an incremental build.  What does it mean ?
  • Builds any assemblies which have changed files from the last build. If there an assembly which has no changes, it won’t be re-built.
  • During the Build option, Visual Studio won’t  delete any intermediate files.

If here is no changes, and try to build it again, it will display message like below – which says .. all the code base are up-to-date

Incase there are multiple projects, all up-to-date projects will be skipped and only the changed files will be built.



Rebuild Solution

As mentioned earlier, rebuild a solution is nothing but clean and build each project in the solution.

Rebuilding a solution first does the “Clean Solution” then execute the “Build Solution” for each project.



Clean Solution
This will remove all intermediary, complied files and clean up the output directories (bin / obj folders) from any previous builds.

Build vs Rebuild

The difference is the way the build and clean sequence happens for every project. Let’s say your solution has two projects, “proj1” and “proj2”. If you do a rebuild it will take “proj1”, clean (delete) the compiled files for “proj1” and build it. After that it will take the second project “proj2”, clean compiled files for “proj2” and compile “proj2”.
But if you do a “clean” and build”, it will first delete all compiled files for “proj1” and “proj2” and then it will build “proj1” first followed by “proj2”.

Difference between Construct and New method in AX 2012

Before proceeding further let's understand what is Static Methods:

Static Methods:

Normally you can't call a method of a class without first creating an instance of that class.

By declaring a method using the static keyword, you can call it without first creating an object because it becomes a class method (i.e. a method that belongs to a class rather than an object).


Static methods are used for methods that do not need to access to an object's state or only use static fields. For example, the main method is a static method.

  • In X++ you can decorate a method with the static keyword. 
  • This keyword instructs the system to create only one instance of the method regardless of how many instances of its class you create. 
  • This single instance is used throughout your Microsoft Dynamics AX session.

Static methods are generally intended for cases where the following criteria are met:
  • The method has no reason to access the member variables that are declared in the classDeclaration block of the class.
  • The method has no reason to call any instance (non-static) methods of the class.

Static Construct Methods:

  • You should create a static construct method for each class. 
  • The method should return an instance of the class.

The construct method must be:

static

named "construct"

In most cases the construct method should be public. 
If the class is instantiated using a newParameter method, then declare the construct method as private

The method should return an instance of the class and contain no other code. construct methods should not have any parameters, or else should have the same parameters as the default new constructor (it is recommended that you do not have parameters on new).

If your class declaration contains parameters, use a static new method as the constructor and use the construct method within the static new method to create an instance of the class.

For partners and customizers, this is the point to add construction functionality for new subclasses (in higher layers), without mixing code with the construct method in the original layer.

Example :

let assume that we have a class ‘AsimConstructClass’ and have a variable ‘Name’ having a parmName method to be set or get


Here I have create a construct method from template, which is returning the instance


I have also create a run method for my logic in a class


Now, finally I have created a job and in this I will get the instance of the class and call the run method in a single call

pic5


static new... Methods:

  • The new method is the default constructor for a class. 
  • The new method should be protected.
  • Do not use it to instantiate the class. Use a construct or a static new… method instead.

It is recommended that you do not have parameters on the new method—use static new… methods instead.

X++ does not support method-name overloading. You must create your own individually named static new… methods with different parameter profiles. 

This enables you to construct a class in more than one way. Similarly, instead of creating default parameters in a new method, create a different static new… method for each possible parameter profile.

If you have created the new method on a subclass, call super() to carry out any necessary initialization that might be implemented in the superclass. 

The call to super() should be the first statement in the method.

static new… Methods
Create one or more static new… methods to instantiate your class.

These new methods have the following characteristics:
  • Are public
  • Are static
  • Have a name prefixed with "new"
  • Are named according to the parameter(s) they take, or logically
  • Usually take only nondefault parameters
  • Always return a valid object of the class's type (instantiated as well as initialized), or throw an error
  • Use a construct method to create an instance of the class
  • Use accessor methods to set the class variables
Here newName takes a parameter,

pic8

Also in the newName code, it is initializing the instance by calling the construct() method which should be private in this case ,so I made it private

pic8

Finally on running it will show

pic10











How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// ...