SSRS report using contract class
SSRS report
Custom SSRS report development:
Requirement: Create following report design using "Customer number" as parameter.
Used object:
1. Temp table (if required)
2. Contract class (if required)
3. DP class
4. Controller class
5. Report design
6. Action menu item
Temp table: If report based on custom table, create new temp table(preferably used as inMemory type) otherwise create extension of standard table and add the required extendable field.
Contract class: Create contract class if report contains any parameter to run the report.
In the following example taken customer number as report parameter
[DataContractAttribute]
public class XXX_CustomerAgingContract
{
AccountNum accountNum;
[DataMemberAttribute("Customer number")]
public AccountNum parmCustomerNum(accountNum _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
}
DP class: DP class is heart and soul of any SSRS report. In DP class we are writing business logic for
calculating values and filled up temp table which are used to show values on report.
Note: We are writing our business logic inside processReport()
[SRSReportParameterAttribute(classstr(XXX_CustomerAgingContract))]
class XXX_CustomerAgingDP extends SRSReportDataProviderBase
{
XXX_CustomerAgingTmp customerAgingTmp;
[SrsReportDataSetAttribute(tableStr(XXX_CustomerAgingTmp))]
public XXX_CustomerAgingTmp getcustomerAgingTmp()
{
select customerAgingTmp;
return customerAgingTmp;
}
public void processReport()
{
contract = this.parmDataContract() as XXX_CustomerAgingContract;
AccountNum accountNum = contract.parmCustomerNum();
while select custTable join salesTable where
custTable.accountNum == accountNum && salesTable.accountNum == custTable.accountNum;
{
// Lets assume temp table name as "XXX_CustTableTmp". This temp table we are using on SSRS report dataset to show data on report. using following code we are fetching values from CustTable and inserting into temp table.
XXX_CustTableTmp.AccountNum = custTable.AccountNum;
XXX_CustTableTmp.CustomerGroup = custTable.CustGroup;
XXX_CustTableTmp.SalesId = salesTable.salesId;
XXX_CustTableTmp.Insert();
}
}
}
Controller class: Controller class used to control report design. To execute SSRS report we need to register DP class in controller class or menu item.
The following example shows the use of controller class;
class XXX_CustomerAgingController extends SrsReportRunController
{
public static client void main(Args _args)
{
XXX_CustomerAgingController controller = new XXX_CustomerAgingController();
controller.parmArgs(_args);
// XXX_CustomerInvoiceReport is the report name and CustomerAgingReportDesign is the report design which we have made the changes.
controller.parmReportName(ssrsReportStr(XXX_CustomerInvoiceReport, CustomerAgingReportDesign));
controller.parmShowDialog(true);
controller.startOperation();
}
}
Action menu item: To run report from UI, we need to create action menu item and attached controller class on action menu item.
Comments
Post a Comment