This tutorial shows how to create an annual sales bar chart and pie chart report on Microsoft Dynamics 365 Business Central C/AL version or Dynamics Navision RTC version using C/AL programming and SSRS (RDL Report). Watch the below video about how to make the report step-by-step.
In this report, the user can input the year that wants to analyze, and the report shows the charts (bar and pie) of monthly net sales (Posted invoices – Posted credit memos) in the year. So you can download the report objects (.txt or .fob) below.
The C/AL code structure of the backend of the report
<strong>OnInitReport()</strong>
<strong>OnPreReport()</strong>
<strong>OnPostReport()</strong>
<strong>MonthLoop - OnPreDataItem()</strong>
<strong>MonthLoop - OnAfterGetRecord()</strong>
StartDate:=DMY2DATE(1,Number,Year);
EndDate:=CALCDATE('<CM>',StartDate);
SalesAmount:=GetNetSale(StartDate,EndDate);
MonthText:=FORMAT(StartDate,3,'<Month Text>');
<strong>MonthLoop - OnPostDataItem()</strong>
<strong>LOCAL GetNetSale</strong>(StartDate : Date;EndDate : Date) NetSale : Decimal
CustLedgerEntry.SETCURRENTKEY("Document Type","Posting Date");
CustLedgerEntry.SETFILTER("Document Type",'%1|%2',CustLedgerEntry."Document Type"::Invoice,CustLedgerEntry."Document Type"::"Credit Memo");
CustLedgerEntry.SETRANGE("Posting Date",StartDate,EndDate);
IF CustLedgerEntry.FINDFIRST THEN
REPEAT
CustLedgerEntry.CALCFIELDS("Amount (LCY)");
NetSale+=CustLedgerEntry."Amount (LCY)";
UNTIL CustLedgerEntry.NEXT=0;
Code language: HTML, XML (xml)
Visit the previous tutorial about, how to create Self-Signed Certificate using Windows PowerShell ISE.