Saturday, 28 December 2013

Cube report with parameter


Creating Cube report - with Parameter

In case of filtering cube records with input of user parameters we need to override Contract class in AX.
The parameter value which will be selected by user will not be in fully qualified parameter which is expected by MDX query. Hence we need to use UI Builder class where we implement conversion of user entered value to fully qualified format.
Let’s proceed with creating a report for APTrial by adding company as parameter.

Creation of Contract Class

Create a Contract Class for APTrialReport and reference the UIBuilder class and Report name.

Creation of UI Builder class

Components of UI Builder class
·         Class Declaration extending SrsReportDataContractUIBuilder.
·         Build method which builds dialog and  dialog controls.
·         getFromDialog() to get the value from dialog and set it to parameter.
·         postRun() to register all lookup methods.
·         processRangeValues()-To convert user entered value to fully qualified value.(customized)
·         Lookup methods.
Copy the code as per below screenshot.











Build method








getFromDialog











postRun




ProcessRangeValues
/// <summary>
/// This method is used to splits range values based on delimiter.
/// </summary>
/// <param name="_values">
/// Passing query criteria values.
/// </param>
/// <param name="_path">
/// fully qulified string for MDX values.
/// </param>
/// <param name="_delimiter">
/// Passing delimiter to seperate values.
/// </param>
/// <param name="_agencyId">
/// Passing agency code to seperate values.
/// </param>
/// <returns>
/// Returns splited values.
/// </returns>
private AifDetail processRangeValues(AifDetail _values, str _path, str _delimiter, str _agencyId = "")
{
    List            rangeParameterValuesList;
    ListEnumerator  listEnumerator;
    List            agencyList;
    ListEnumerator  agencyListEnumerator;
    AifDetail       rangeParameterValuesString;

    rangeParameterValuesString  = '';
    rangeParameterValuesList    = strSplit(_values, _delimiter);

    if (_agencyId != #Empty)
    {
        agencyList = strSplit(_agencyId, _delimiter);

        agencyListEnumerator = agencyList.getEnumerator();

        while (agencyListEnumerator.moveNext())
        {
            if (strLRTrim(agencyListEnumerator.current()) != '')
            {
                if (rangeParameterValuesList)
                {
                    listEnumerator = rangeParameterValuesList.getEnumerator();

                    while (listEnumerator.moveNext())
                    {
                        if (strLRTrim(listEnumerator.current()) != '')
                        {
                            rangeParameterValuesString += _path + strLRTrim(agencyListEnumerator.current()) +']&[' + strLRTrim(listEnumerator.current()) + ']' + _delimiter;
                        }
                    }
                }
            }
        }
    }
    else
    {
        if (rangeParameterValuesList)
        {
            listEnumerator = rangeParameterValuesList.getEnumerator();

            while (listEnumerator.moveNext())
            {
                if (strLRTrim(listEnumerator.current()) != '')
                {
                    rangeParameterValuesString += _path + strLRTrim(listEnumerator.current()) + ']' + _delimiter;
                }
            }
        }
    }

    return subStr(rangeParameterValuesString, 0, strLen(rangeParameterValuesString) - 1);
}

Lookup method












Compile the UIBuilder class and Contract class.

Create MDX Query with Parameter

Create a MDX query with AgencyMDX as parameter.
Click Execute button.

Click OK.

Create a precision design just as the report developed before. Deploy the report.


Create an output menu item to open the report.




Sunday, 1 December 2013

Creation of Dynamics AX Cube report (Analysis Report)

Its quite complex to proceed with developing Cube reports from Scratch.
Lets proceed with learning from installation of Analysis server reports
Processing of cube:
·         Install Analysis server and Reporting server component in AX.
·         Enter Analysis server instance name in AX analysis server form.
·         
·         
·         It does not matter if OLAP databases tab does not hold any record(Database).
·         To deploy and process report Tools->Business Intelligence tools-> SQL Server Analysis Services wizard.
·         Run the wizard. Select deploy (If you are going to process existing analysis cube)
·         
·         You will be able to find the existing project available in AX in analysis server project section.
·         Click Next and check process option. It is good to process the analysis server project from visual studio project as it is quite quicker and errors will be detailed. Another advantage is you can have a option to deploy only required cube rather than deploying aall existing cubes through wizard.
·         Finish the wizard.
Let us write a MDX query for Accounts Payable Cube.
Login to SQL Server-> Analysis service->Right Click database

Enter following query and run . You can drag and drop measures and dimensions from left window pane to code editor.
Keep this aside and create a SSRS report in VS and add SSRS report item to this project solution.

Create a Dataset and update the datasource property to DynamicsAXOLAP.
Click Query window and paste the query.
·         Execute the query.


To get all fields in datasource  you must get atleast one record when you executre the query in dialog. If not you will get only measures populated.
Rename the fields and create a design and deploy the report.
Create a output menu item to use this analysis report.