The report development is based on the MVC framework pattern. As part of this framewoek there are 2 main classes required for report development. Firstly, the contract class to store the necessary data for report generation. Secondly, we need the data provider class that is used to encapsulate the business logic to process for generation of the report.
Following are the steps and necessary constructs/ data attributes required to create a report from the scratch
- Start by creating a contract class which would have the necessary fields to capture data on the report request stage. These data fields are then later used in the DataProvider class to filter our the required data.
[DataContractAttribute]
class SPYSalaryHistoryContract implements SysOperationValidatable
{
FromDate fromDate;
ToDate toDate;
[DataMemberAttribute("FromDate"),
SysOperationLabelAttribute(literalStr(@SPY1278)),
SysOperationHelpTextAttribute(literalStr(@SPY1278))]
public FromDate parmFromDate(FromDate _fromDate = fromDate)
{
fromDate = _fromDate;
return fromDate;
}
[DataMemberAttribute("ToDate"),
SysOperationLabelAttribute(literalStr(@SPY1279)),
SysOperationHelpTextAttribute(literalStr(@SPY1279))]
public FromDate parmToDate(FromDate _toDate = toDate)
{
toDate = _toDate;
return toDate;
}
public boolean validate()
{
boolean ret = true;
if(fromDate > toDate)
ret = checkFailed('@SPY:DateValidationMsg');
return ret;
}
}
2. Create the DataProvider class.
The data provider class should extend from the SrsReportDataProviderPreProcess method. When extended from this class the data provider will provide the necessary structure to populate the data table before the report is triggered.
[
SRSReportParameterAttribute(classStr(SPYSalaryHistoryContract)),
SRSReportQueryAttribute(queryStr(HcmWorkerLookup))
]
class SPYSalaryHistoryDP extends SrsReportDataProviderPreProcess
{
SPYPromotionSalaryTableTmp promotionSalaryTableTmp;
[SRSReportDataSetAttribute(tableStr(SPYPromotionSalaryTableTmp))]
public SPYPromotionSalaryTableTmp getSPYPromotionDetailsTmp()
{
select promotionSalaryTableTmp;
return promotionSalaryTableTmp;
}
public void setTableConnections()
{
promotionSalaryTableTmp.setConnection(this.parmUserConnection());
}
public void processReport()
{
Query query;
QueryRun queryRun;
FromDate fromDate, toDate;
SPYSalaryHistoryContract contract = this.parmDataContract() as SPYSalaryHistoryContract;
fromDate = contract.parmFromDate();
toDate = contract.parmToDate();
query = this.parmQuery();
queryRun = new QueryRun(query);
while(queryRun.next())
{
}
}
}
Once the above constructs are created a new SSRS report can be created. To start the designing we will have to begin by adding DataSource which should be Report Data Provider. When can then specify a Query to link the DataSource to a table in the DP class.
Two important attributes are used in RDP classes are:
- SRSReportParameterAttribute: defines the data contract class that will be used by this report to prompt for parameter values. If the RDP class contains any parameters this define this attribute at the beginning of the class.
- SRSReportQueryAttribute: specifies which AOT query will be used in this report. If the RDP class uses an AOT query to process data, define this attribute at the beginning of the class. However, for this attribute to work the Dynamic Filter should be set to true on the DataSet node of the report as shown below