64) How to create report and initialed the contract value
Requirement :- i am going to create a query based report and in that want to pass the range using the contract and controller class.
In this i will tell you how to hold the parameter value and pass in the class.
step 1 :- Create a query based report without any range mention in that and create simple report with the manually add the 3 parameter ( from date, To Date and AssetID)
=================================================================
Step 2 :- Create a contract Class :-
[
SrsReportNameAttribute(ssrsReportStr(AvaEntAssetChecklistDetailReportCopy, Report))
]
public class TestSubReportContract extends SrsReportRdlDataContract
{
public const str ParameterNameFromDate = 'FromDate';
public const str ParameterNameToDate = 'ToDate';
public const str ParameterNameAssetID = 'AssetID';
FromDate fromDate;
ToDate todate;
EntAssetObjectID assetID;
[DataMemberAttribute('FromDate')]
public FromDate parmFromDate(FromDate _fromDate = DateTimeUtil::date(this.getValue(ParameterNameFromDate)))
{
// fromDate = _fromDate;
this.setValue(ParameterNameFromDate, DateTimeUtil::newDateTime(_fromDate, 0));
return _fromDate;
}
[DataMemberAttribute('Todate')]
public todate parmToDate(ToDate _todate = DateTimeUtil::date(this.getValue(ParameterNameToDate)))
{
// todate = _todate;
this.setValue(ParameterNameToDate, DateTimeUtil::newDateTime(_toDate,86399));
return _toDate;
}
[DataMemberAttribute('AssetID')]
public EntAssetObjectID parmAssetID(EntAssetObjectID _assetID =this.getValue(ParameterNameAssetID))
{
// assetID = _assetID;
this.setValue(ParameterNameAssetID, _assetID);
return _assetID;
}
}
===============================================================
Step 3 :- Create a controller class and pass the range :-
class TestSubReportController extends SrsReportRunController
{
#define.ReportName ('AvaEntAssetChecklistDetailReportCopy.Report')
protected void preRunModifyContract()
{
// TestSubReportContract contract;
var contract = this.parmReportContract().parmRdlContract() as TestSubReportContract;
Query query = this.parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey());
FromDate fromDate = contract.parmFromDate();
ToDate toDate = contract.parmToDate();
EntAssetObjectID AssetId = contract.parmAssetID();
// Modify the query contract based on fromDate & toDate.
SrsReportHelper::addFromAndToDateRangeToQuery(query,
fromDate,
toDate,
tableNum(AvaEntAssetChecklistDetailView),
fieldNum(AvaEntAssetChecklistDetailView, RegisteredDateTime));
// Modify the query contract based on DepreciationBookId.
//SrsReportHelper::addParameterValueRangeToQuery(query,
// tableNum(AvaEntAssetChecklistDetailView),
// fieldNum(AvaEntAssetChecklistDetailView, ObjectID),
// AssetId);
super();
}
public static TestSubReportController construct(Args _args)
{
TestSubReportController controller = new TestSubReportController();
controller.parmReportName(#ReportName);
controller.parmArgs(_args);
return controller;
}
public static void main(Args args)
{
TestSubReportController::construct(args).startOperation();
}
}
+=====================================================================
Step 4 :- Create a action menu Itme and calls this controller class there and run the report
Happy Daxing
Comments
Post a Comment