• Skip to main content
  • Skip to primary sidebar
  • Home
  • About
  • Recommended Readings
    • 2022 Book Reading
    • 2023 Recommended Readings
    • Book Reading 2024
    • Book Reading 2025
  • Supply Chain Management Guide
  • PKM
  • Microsoft Excel

Ali Raza Zaidi

A practitioner’s musings on Dynamics 365 Finance and Operations

Dynamics Ax 2012 Reporting SSRS Reports.

TempDB, SrsReportDataProviderPreProcessTempDB And long Running Report Dynamics 365 Finance and operations

October 18, 2022 by alirazazaidi

Recently I got interesting issue. I developed the report based on RDP Class. I have to populate temp table. And based on this temp table I have to aggregate some calculation like sum, Average on Group by.

But when I populate another table based on this aggregation. Report starts to go long awaiting state. I dont know the reason. Later I found that I did not give active connection to temp table variables.

I added following line of code in reports and report processing reduce to less then 2 minutes

this.takeOwnershipOfTempTable(_BEGroupWiseSalarySheetTmp);
this.takeOwnershipOfTempTable(_BEBranchWiseSalarySheetTmp);

Custom lookup UIBuilder SSRS RDP Dynamics 365 for finance and operations

March 4, 2020 by alirazazaidi

Hi, Today I have simple code snippet to create a custom lookup in SSRS Reports in Dynamics 365 for finance and operations.

public class MyUIBuilder extends SrsReportDataContractUIBuilder
{

    private DialogField vendordf,dialogbranch;
    
    MyDC     contract;
    public void postBuild()
    {
        super();

        contract = this.dataContractObject();

        // binding dialogs with contract fields

        vendordf = this.bindInfo().getDialogField(this.dataContractObject(),
            methodStr(MyDC, parmHcmPerfPeriodId));
        dialogbranch = this.bindInfo().getDialogField(this.dataContractObject(),
            methodStr(MyDC, parmOMOperatingUnitNumber));

       dialogbranch.registerOverrideMethod(methodStr(FormStringControl,lookup),methodStr(BEHCMReviewUIBuilder,divisionCodeLookup),this);

  
        vendordf.registerOverrideMethod(methodStr(FormStringControl,lookup),methodStr(BEHCMReviewUIBuilder,PerfPeriodIdLookup),this);
       
    }

    public void postRun()
    {
    
    }

 
    private void PerfPeriodIdLookup(FormStringControl divisionCodeLookup)
    {
        Query                   query = new Query();
        QueryBuildDataSource    qbd, qbdPerson;
            QueryBuildDataSource qbds;
        QueryBuildDataSource qbdsJoin;
        SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(HcmPerfPeriod), divisionCodeLookup);
        qbds= query.addDataSource(tableNum(HcmPerfPeriod));
          sysTableLookup.parmQuery(query);
           sysTableLookup.addLookupfield(fieldNum(HcmPerfPeriod, PerfPeriodId), true);
     
        sysTableLookup.parmQuery(query);
        sysTableLookup.parmUseLookupValue(False);
        sysTableLookup.performFormLookup();
    }

    private void divisionCodeLookup(FormStringControl divisionCodeLookup)
    {
        Query          query;
        QueryBuildDataSource  qbds,qbds1;
        SysTableLookup     sysTableLookup;
        DimensionAttribute   dimAttr;
        ;
        sysTableLookup = SysTableLookup::newParameters(tablenum(OMOperatingUnit),divisionCodeLookup);
        sysTableLookup.addLookupfield(fieldnum(OMOperatingUnit, OmoperatingunitNumber));
        sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,Name));
        query = new Query();
        qbds = query.addDataSource(tableNum(OMOperatingUnit));
        qbds.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(queryvalue(OMOperatingUnitType::OMDepartment));
        sysTableLookup.parmQuery(query);
        sysTableLookup.parmUseLookupValue(False);
        sysTableLookup.performFormLookup();
    }

}

float value conversion in string SSRS expression and decimal points SSRS dynamics ax 2012 R3.

September 29, 2017 by alirazazaidi

 

 

Today I have to record very small tip. During development of on SSRS report for Dynamics Ax 2012 R3, End user wants a row at the report footer for  analysis. he wants some kind of percentage  calculation with ‘%’.  A For this I have to use CStr ssrs expression function  like

 

Ctr(((sum(DataSet!field.Value) / sum(DataSet!field.Value)))*100)+”%”.

 

Now it is string and shows number of decimal as it result from division. For example  5.4356333. But end user wants formatting like 5.43 .

It is string or text value and SSRS textbox formatting is not apply on it.

 

Following SSRS expression works for me.

 

 

 

Left(CStr(5.4356333),instr(CStr(5.4356333),”.”)+2)

 

 

My Updated expression is something like this

 

Left(CStr(IIF(Parameters!ProductionReportBM2DS_ItemName.Value = “ITEM-00000420”,((sum(Fields!Scrap.Value)/sum(Fields!TotalConsumption.Value))*100),((sum(Fields!CutLength.Value)/sum(Fields!TotalConsumption.Value))*100))),instr(CStr(IIF(Parameters!ProductionReportBM2DS_ItemName.Value = “ITEM-00000420″,((sum(Fields!Scrap.Value)/sum(Fields!TotalConsumption.Value))*100),((sum(Fields!CutLength.Value)/sum(Fields!TotalConsumption.Value))*100))),”.”)+2) +”%”

Skip certain values Report group sum SSRS Dynamics Ax 2012 R3. Dynamics 365 for operations

July 3, 2017 by alirazazaidi

There is again small tips. Let me share you again scenario. Suppose you have to show customer Sale With customer group level. And group footer want to sum of Sales of that group. Now requirement is that customer with certain sub classification will skip in group sum. For example those customer who are on hold or blocked will not shown in report group sum, but shown in report detail

I was developing RDP based reports. So I add a int field in table. So I can mark specific record need to skip at group level sum.

I update the following SSRS expression to skip certain records at group level.

=Sum(iif(Fields!Flag.Value= 0, Cdbl(Fields!Value.Value), 0.0),”Group Name”)

Serial Number in Report Group SSRS Dynamics Ax 2012 R3.

July 3, 2017 by alirazazaidi

Today I have small tip. Let me share a scenario. Suppose you have to display Customer group as report level group and customer at detail level who did purchased products from your organization in given period of time.

Serial number on detail level can be achieved by RowNumber(“Scope Name”)

But serial number shown on Group level is tricky because RowNumber not works there. For example in above mention scenario, Client wants serial number on Customer Group instead of Customer at detail level.

I used following single line SSRS expression helps me to achieve this.

=Runningvalue(Fields!FieldName.Value,countdistinct,”Dataset1″)

Time field on SSRS shows time format Report Dynamics Ax 2012

October 28, 2016 by alirazazaidi

Today is another small tip,

I was developing a custom report. Queried table stored the date and time in separate fields ie. Transdate and transtime. On  mapping the transtime to report, its showed time format. Instead of time value.

2016-10-28_19-18-27

For it solution, I added the string field on report temp table and then convert the time with time2str function and map to the field.

Complete statement is below.

TableTmp.StransTime  = time2Str(_Trans.transTime, TimeSeparator::Colon, TimeFormat::AMPM);

 

As result, report will display the trans time instead of its format.

2016-10-29_1-56-07

How to run RDP based report from X++ and passing parameter using Data contract.

July 19, 2016 by alirazazaidi

Interesting, I was modifying some RDP based report, I found that parameter was passed to report through custom table, As report will run form button, and based on current selected record. So former developer did that on pressing button, selected value inserted some custom table. When report run, query on table and fetch required value form custom table and whole report logic run on that value. That approach works fine, single user environment. Problem I found to send parameter to report through x++ code. I found SrsReportRunController works wonder here.

Suppose we are running some report for customer, And Report Name is customer Report and we have to pass current customer account on form as parameter. If you report is based on Report data provider than following code snippet works for you.

 

 

 

SrsReportRunController          controller = new SrsReportRunController();

CustomerReprtDC  rdpContract = new CustomerReprtDC  ();

SRSPrintDestinationSettings     settings;

super();

controller.parmReportName(ssrsReportStr(CustomerReport,CustomerCopy));

 

 

controller.parmShowDialog(false);

rdpContract.parmCustAccount(CustTable.AccountNum);

controller.parmReportContract().parmRdpContract(rdpContract);

controller.startOperation();

How to handle long running reports in Dynamics Ax 2012 R3

July 8, 2015 by alirazazaidi

 

Consider a scenario that we are listing  sale line for  customers on RDP based report. Data is huge on server and report time out occur.

In Dynamics Ax 2012 R3 provide new class “SrsReportDataProviderPreProcessTempDB”  use this class instead of SRSReportDataProviderBase

For base for this report we please follow below link

RDP or Business logic based SSRS Reports in Dynamics Ax 2012 R3.

 

If you report is already developed you have to require three changes

Change 1:  RDP report always return table of type TempDB, If not then change it.

 

TempDbChange 2-Extend the class SrsReportDataProviderPreProcessTempDB instead of SRSReportDataProviderBase.

[

 

SRSReportParameterAttribute(classstr(CustomerSalesDataContract))

]

 

class CustomerSalesDataProvider extends  SrsReportDataProviderPreProcessTempDB

{

CustomerSaleTemp _CustomerSaleTemp;

}

 

Change 3.  Set report connection to temp data table.

The temp table connection string statement will be look like

 

  _CustomerSaleTemp.setConnection(this.parmUserConnection());

 

Rest of the logic remains same on report.

RDP or Business logic based SSRS Reports in Dynamics Ax 2012 R3.

July 8, 2015 by alirazazaidi

RDP or Business logic based SSRS Reports in Dynamics Ax 2012 R3.

 

Logic based report in MS Dynamics Ax 2012 can be develop in following steps

 

  1. Create a temporary table
  2. Define the report parameters
  3. Add business logic for the report
  4. Create a reporting project
  5. Bind a report to a report data provider class

 

In graphical shape RDP reports will be as

Code Based Report

Image Inspiration http://dynamics-ax.blogspot.com/2011/12/ax-2012-ax-ssrs-report-design-concepts.html

 

 

Now consider a scenario, where we have to display list of Item, quantity, Price and total amount sold to customers. It is relatively simple report but have to build this report based on RDP or Report Data Provider framework.

 

First step to open an Ax client. When Ax client open press Ctrl + shift +W keys to open Dev environment or AOT.

 

For all artifacts for report development will be a single place and we did not move to node to node in AOT we have to create a AX project.

 

You can find projects at View=>Projects => Public project.

Create a new project at and rename it with “CustomRDBReport”

ss

 

 

 

Step 1 create a temp table.

The major step in RDP report is decision the fields require in report, create a temp table and add these field in temp table. For current example what fields we required on report are as follow

 

  • CustomerAccount
  • CustomerName
  • ItemId
  • ItemName
  • SalesPrice
  • SalesQuantity
  • SalesAmount

 

If we see these fields exists in SalesLine Table. So we drag them into our temp table, and rename them accordingly

Right click on project and create at table with Name “CustomerSalesTemp”,

TableCreation

 

From property window rename the table as “CustomerSalesTemp” and set  TableType to   tempDb

TempDb

 

Now close all window, open AOT and opens salesLine table. From top menu click on windows => Tile and both tables comes in parallel to each other

Tiltle

and start drag and drop fields in temp table

Drag fields

Now save the table and rename the fields accordingly if required. Also add a new field with Name CustomerName with extended data Type with Name.

 

 

Right click compile and synchronize table.

 

 

 

 

Now create a AOT Query with Name QSalesLine. Add data source on SalesLine and Add following fields on Salesline table

QSalesLine

 

For Date Fileter, we will use ShippingDateConfirmed on Date.

Safe this query.

 

Step 2 define the report parameters

For current report we required three parameters, Customer, From date and To date.

In Report Data Provider framework which is based on WCF, we have to create a data contract class.

Create a new class in, rename it, CustomerSalesDataContract.

In its declaration section create three variables

 

[DataContractAttribute]

class CustomerSalesDataContract

{

CustAccount CustomerAccount;

TransDate FromDate;

TransDate ToDate;

}

 

 

 

Now Create three data method

[

DataMemberAttribute(identifierStr(CustAccount)),

SysOperationLabelAttribute (“Customer Account”),

SysOperationHelpTextAttribute(“Customer Account”),

SysOperationDisplayOrderAttribute(“1”)

]

public CustAccount  parmCustomerAccount(CustAccount  _CustomerAccount = CustomerAccount)

{

CustomerAccount = _CustomerAccount;

return CustomerAccount;

}

 

 

[

DataMemberAttribute(identifierStr(FromDate)),

SysOperationLabelAttribute (“From Date”),

SysOperationHelpTextAttribute(“FromDate”),

SysOperationDisplayOrderAttribute(“2”)

]

public TransDate  parmFromDate(TransDate  _FromDate = FromDate)

{

FromDate = _FromDate;

return FromDate;

}

 

 

[

DataMemberAttribute(identifierStr(ToDate)),

SysOperationLabelAttribute (“To Date”),

SysOperationHelpTextAttribute(“To Date”),

SysOperationDisplayOrderAttribute(“3”)

]

public TransDate  parmToDate(TransDate  _ToDate = ToDate)

{

ToDate = _ToDate;

return ToDate;

}

 

 

 

 

Step 3 Add business logic for the report.

In Report data provider framework we have to write Data provider classes, which contain business logic to populate temp table. For this we have to add create a new class “CustomerSalesDataProvider”

Extend this class SRSReportDataProviderBase

 

 

[

 

SRSReportParameterAttribute(classstr(CustomerSalesDataContract))

]

 

class CustomerSalesDataProvider extends  SRSReportDataProviderBase

{

CustomerSaleTemp _CustomerSaleTemp;

}

 

 

This Class two method, first is return the temp table, and second one is which contains the logic to populate  temp table.

 

[SRSReportDataSetAttribute(“CustomerSaleTemp”)]

public CustomerSaleTemp getCustomerSaleTemp()

{

select * from _CustomerSaleTemp;

return _CustomerSaleTemp;

}

 

 

 

public void processReport()

{

TransDate _FromDate;

TransDate _Todate;

AccountNum _CustAccount;

CustomerSalesDataContract dataContract;

 

Query query;

QueryRun queryRun;

QueryBuildDataSource queryBuildDataSource;

QueryBuildRange queryBuildRange;

QueryBuildRange ShippingDateConfirmedFilter;

SalesLine querySalesLine;

 

 

query = new Query(queryStr(“QSaleLine”));

dataContract = this.parmDataContract();

_CustAccount = dataContract.parmCustomerAccount();

_FromDate = dataContract.parmFromDate();

_Todate= dataContract.parmToDate();

 

queryBuildDataSource = query.dataSourceTable(tablenum(SalesLine));

if (_CustAccount)

{

queryBuildRange = queryBuildDataSource.findRange(fieldnum(SalesLine, CustAccount));

if (!queryBuildRange)

{

queryBuildRange = queryBuildDataSource.addRange(fieldnum(SalesLine, CustAccount));

}

}

ShippingDateConfirmedFilter = SysQuery::findOrCreateRange(query.datasourceTable(tableNum(SalesLine)),fieldNum(SalesLine,ShippingDateConfirmed));

ShippingDateConfirmedFilter.value(SysQuery::range(_FromDate,_Todate));

 

queryRun = new QueryRun(query); ttsbegin;

while(queryRun.next())

{ _CustomerSaleTemp.clear();

querySalesLine = queryRun.get(tablenum(SalesLine));

_CustomerSaleTemp.SalesPrice =  querySalesLine.SalesPrice;

_CustomerSaleTemp.ItemId =  querySalesLine.ItemId;

_CustomerSaleTemp.ItemDescription =  querySalesLine.Name;

_CustomerSaleTemp.SalesQty =  querySalesLine.QtyOrdered;

_CustomerSaleTemp.CustAccount =  querySalesLine.CustAccount;

_CustomerSaleTemp.CustomerName = CustTable::find(querySalesLine.CustAccount).name();

_CustomerSaleTemp.insert();

 

 

 

 

}

ttscommit;

 

}

 

 

 

 

 

Now compile the class, generate Incremental CIL.

Step 4 create a reporting project

Now open Visual studio and create Model project say “CustomSalesLineReport”.

VisualStudio

From solution explorer, create a new report rename it RDPSalesLineReport

RDPSalesLineReport

 

 

Step 5 Bind a report to a report data provider class

 

Now double click on report and open it in

ExpandDataSet

 

 

Add new DataSet and rename it “DSSalesLine”. On right click and from property window set Data Source Type to “Report Data Provider”

 

RDPSettings

 

And click on Query and from browser window select The data provider class we created in previous step

CustomerSalesDataProvider

 

Click ok to create fields

FieldsDetails

 

Now drag and drop data set to Design node in report to create AutoDesign.  Rename it “RDPSalesLine”

 

Drag and drop

Expand “RDPSalesLine” design and drag and drop CustAccount field from Data Set to Group and sort nodes

SortAndGroup

 

Expand parameter of report and open the property of CustAccount parameter and set its allow blank to true and nullable to true, so if no customer is selected, report will run for all customer in legal entity

CustAccountSales

Save the report compile it, deploy it and add to AOT

 

Now switch back to AOT.  Create a new menu Item under Display node.

Mnu

 

And set menu item Name as “mnuRDPSaleLine” and set its properties as follow

MnuSettings

 

Save it and right click on menu item and open it

 

Report Dialog

 

Set values for From Date and To date and run the report, Report will work with business logic as follow

 

Sales

 

 

Repeat the column header row on every page Tablix SSRS dynamics Ax 2012

October 13, 2014 by alirazazaidi

During SSRS report for Dynamics Ax 2012, I found that when report goes on multiple pages, column header did not appear all page except the first one.

I fix this problem by setting some properties to true.

 

Select the tablix and below right side of columns group header and click there on small arrow head and select the advance Mode.

10-13-2014 11-03-17 AM

 

This will open the row group  header and column groups like below picture.

10-13-2014 11-06-34 AM

 

Now right click on top static in row groups, or Press F4 to open the properties window.

 

 

From property window, set propertyRepeatOnNewPage to True. Also set KeepWithGroup property to After

 

10-13-2014 11-06-24 AM

 

. When you deploy the report. Column header will appear on each page.

Next Page »

Primary Sidebar

About

I am Dynamics AX/365 Finance and Operations consultant with years of implementation experience. I has helped several businesses implement and succeed with Dynamics AX/365 Finance and Operations. The goal of this website is to share insights, tips, and tricks to help end users and IT professionals.

Legal

Content published on this website are opinions, insights, tips, and tricks we have gained from years of Dynamics consulting and may not represent the opinions or views of any current or past employer. Any changes to an ERP system should be thoroughly tested before implementation.

Categories

  • Accounts Payable (2)
  • Advance Warehouse (2)
  • Asset Management (3)
  • Azure Functions (1)
  • Books (6)
  • Certification Guide (3)
  • Customization Tips for D365 for Finance and Operations (62)
  • D365OF (59)
  • Data Management (1)
  • database restore (1)
  • Dynamics 365 (58)
  • Dynamics 365 for finance and operations (135)
  • Dynamics 365 for Operations (165)
  • Dynamics AX (AX 7) (134)
  • Dynamics AX 2012 (274)
  • Dynamics Ax 2012 Forms (13)
  • Dynamics Ax 2012 functional side (16)
  • Dynamics Ax 2012 Reporting SSRS Reports. (31)
  • Dynamics Ax 2012 Technical Side (52)
  • Dynamics Ax 7 (65)
  • Exam MB-330: Microsoft Dynamics 365 Supply Chain Management (7)
  • Excel Addin (1)
  • Favorites (12)
  • Financial Modules (6)
  • Functional (8)
  • Implementations (1)
  • Lifecycle Services (1)
  • Logseq (4)
  • Management Reporter (1)
  • Microsoft Excel (4)
  • MS Dynamics Ax 7 (64)
  • MVP summit (1)
  • MVP summit 2016 (1)
  • New Dynamics Ax (19)
  • Non Defined (9)
  • Note taking Apps (2)
  • Obsidian (3)
  • Personal Knowledge Management (2)
  • PKM (13)
  • Power Platform (6)
  • Procurement (5)
  • procurement and sourcing (5)
  • Product Information Management (4)
  • Product Management (6)
  • Production Control D365 for Finance and Operations (10)
  • Sale Order Process (10)
  • Sale Order Processing (9)
  • Sales and Distribution (5)
  • Soft Skill (1)
  • Supply Chain Management D365 F&O (3)
  • Tips and tricks (278)
  • Uncategorized (165)
  • Upgrade (1)
  • Web Cast (7)
  • White papers (4)
  • X++ (7)

Copyright © 2025 · Magazine Pro On Genesis Framework · WordPress · Log in