Step by step SSRS Report in d365

Description:- 

Step-1: Create table and name it “dev_GeneralJournalReportTmp”. To create table right click on Solution explorer tab and over select option and select New item…


Below popup will open in that select DataModel node and select Table and name it “dev_GeneralJournalReportTmp”.

To add Fields in the table right click on the Fields node and select data type which data type fields you want to add in the table. If you want to add relation with another table then you have to add that table extension in the current project. If you want to add edt then select the EDT fields from the selected fields property. It will might take time to add EDT in the selected fields.

 
Please look below I have created fields in the table.



Now change the table type property to Regular to TempDB.



Now next step is report parameters. For this purpose we use Data contract class. In current report we required parameters base on Extended Data Type LedgerJournalNameId,FromDate and ToDate. At simplest our data contract class will be look like as follow.

To Add Contract Class in the project right click on Solution explorer tab and over select option and select New item… on the Code table select class and name it “dev_GeneralJournalReportContract”.



Now create code for parameter like below.

[DataMemberAttribute]
class dev_GeneralJournalReportContract
{
    LedgerJournalNameId LedgerJournalNameId;
    TransDate           FromDate, ToDate;

    [DataMemberAttribute('From date')]
    public TransDate ParmFromDate(FromDate _FromDate=FromDate)
    {
        FromDate = _FromDate;
        return FromDate;
    }

    [DataMemberAttribute('To date')]
    public TransDate ParmToDate(ToDate _ToDate=ToDate)
    {
        ToDate = _ToDate;
        return ToDate;
    }

    [DataMemberAttribute('Journal Name')]
    public LedgerJournalNameId ParmLedgerJournalNameId(LedgerJournalNameId _LedgerJournalNameId=LedgerJournalNameId)
    {
        LedgerJournalNameId = _LedgerJournalNameId;
        return LedgerJournalNameId;
    }
}

Now we required to write some logic which you above mention class as its data contract and populate the custom temp table we build in pervious step.
Now create another class like above and name it “dev_GeneralJournalReportDP”.

 

Create methods and your login to get data like below.

[SrsReportParameterAttribute(classstr(dev_GeneralJournalReportContract))]
class dev_GeneralJournalReportDP extends SRSReportDataProviderBase
{
    dev_GeneralJournalReportTmp dev_GeneralJournalReportTmp;
    dev_GeneralJournalReportContract Contract;

    public void ProcessReport()
    {
        LedgerEntryJournal                  LedgerEntryJournal;
        GeneralJournalEntry                 GeneralJournalEntry;
        GeneralJournalAccountEntry          GeneralJournalAccountEntry;
        LedgerJournalTrans                  LedgerJournalTrans;
        LedgerJournalTable                  LedgerJournalTable;
        DimensionAttributeValueCombination  DimensionAttributeValueCombination;
        MainAccount                         MainAccount;
        LedgerJournalName                   LedgerJournalName;
        TransDate                           _FromDate,_ToDate;
        LedgerJournalNameId                 _LedgerJournalNameId;

        Contract = this.parmDataContract();
        _FromDate = Contract.ParmFromDate();
        _ToDate = Contract.ParmToDate();
        _LedgerJournalNameId = Contract.ParmLedgerJournalNameId();

        while select * from GeneralJournalAccountEntry
        order by GeneralJournalEntry.SubledgerVoucher asc
        join GeneralJournalEntry
        where GeneralJournalEntry.RecId == GeneralJournalAccountEntry.GeneralJournalEntry
        && (!_FromDate || GeneralJournalEntry.AccountingDate >= _FromDate)
        && (!_ToDate || GeneralJournalEntry.AccountingDate <= _ToDate)
        join DimensionAttributeValueCombination
        where DimensionAttributeValueCombination.RecId == GeneralJournalAccountEntry.LedgerDimension
        join MainAccount
        where MainAccount.RecId == GeneralJournalAccountEntry.MainAccount
        join LedgerEntryJournal
        where LedgerEntryJournal.RecId == GeneralJournalEntry.LedgerEntryJournal
        join LedgerJournalTable
        where LedgerJournalTable.JournalNum == LedgerEntryJournal.JournalNumber
        join LedgerJournalName
        where LedgerJournalName.JournalName == LedgerJournalTable.JournalName
        && (!_LedgerJournalNameId || LedgerJournalName.JournalName == _LedgerJournalNameId)
        {
            dev_GeneralJournalReportTmp.JournalName = LedgerJournalName.JournalName;
            dev_GeneralJournalReportTmp.JournalNum = LedgerJournalTable.JournalNum;
            dev_GeneralJournalReportTmp.AccountingDate = GeneralJournalEntry.AccountingDate;
            dev_GeneralJournalReportTmp.SubledgerVoucher = GeneralJournalEntry.SubledgerVoucher;
            dev_GeneralJournalReportTmp.MainAccountId = MainAccount.MainAccountId;
            dev_GeneralJournalReportTmp.Name = MainAccount.Name;
            if(GeneralJournalAccountEntry.TransactionCurrencyAmount < 0)
            {
                dev_GeneralJournalReportTmp.Credit = GeneralJournalAccountEntry.TransactionCurrencyAmount;
            }
            if(GeneralJournalAccountEntry.TransactionCurrencyAmount > 0)
            {
                dev_GeneralJournalReportTmp.Debit = GeneralJournalAccountEntry.TransactionCurrencyAmount;
            }
            dev_GeneralJournalReportTmp.insert();
        }
    }

    [SrsReportDataSetAttribute('dev_GeneralJournalReportTmp')]
    public dev_GeneralJournalReportTmp GetData()
    {
        select dev_GeneralJournalReportTmp;
        return dev_GeneralJournalReportTmp;
    }

}

At this step build the solution, never forget to check the project Sychronized database on build set to true.
Right click Solution explorer and select property.
 


Now add new report in project.
right click on Solution explorer tab and over select option and select New item… on that select Reports Node and Select report and name it “dev_GeneralJournalReport".



Double click on Report in solution and open in designer screen. And right click on datasets and create new Data Set.



From new data set update the following properties. Data Source Type to Report Data provider. Change Name to dev_GeneralJournalReportDP
Click on Query and from dialog select the data provider class we create some above screen.



Click on next and select which fields you want it to get in the report dataset. After click OK.



After that you can see all fields which you had selected in the previous form.



After that expand the parameter node from the report and set the prompt string which will display in the report lable.



Now right click on designer node of report and click on precision design.



In precision design, we can create report designer by our need.
New designer will be added, rename it and double click to open it. from left pane, toolbar to drag to table to add in designer.



When all fields are added in report. Right click outside the report body and click on report property.

 

And select report print layout. Our target is A4 page. so set it from report properties.

 

Now right click on report body and check its with. Its width must be under 6 because at run time 1 inch on both side must be skip.
After that right click on report in solution explorer and click on deploy.



After the add new display menu Item update the its following properties



Here there is one advancement, In 2012 there is very difficult to debug report. But in Dynamics 365 for operation is its very simple. Just put break point and set report as starting object and run the project.



Now new browser window you find similar form.

 
Select parameter. Click on ok
And my break open hit.



So it is very easy to debug report.
So our report logic fine, but one step is pending which is report should be run from Client with particular module.
So I decide to add this report in General journal module and under Inquery report . For this purpose we have to create a new menu extension.



New menu extension added in solution explorer.



New menu extension added in solution explorer.



Expand menu extension in designer and drag display menu in required menu



From property update “Display In Content Area” to true to create show crumb bar.



Now save and compile again the project.
And open client url in Browser
Login and goes in Sales module for identification purpose, I set the label of display menu as “General Journal report”.



Click on it find report parameter dialog

 
So our report is running successfully.

Related Posts

Previous
Next Post »

Thanks for comments.....