66) Create report using contract and DP Class
There is requirement to create report using contract and DP Class
Step 1 - create a Contract Class
class AvaEntAssetChecklistReportContract
{
TransDate fromDate;
TransDate toDate;
EntAssetObjectID assetID;
/// <summary>
/// Gets or sets the value of the datacontract parameter RecordId.
/// </summary>
/// <param name="_recordId">
/// The new value of the datacontract parameter fromDate; optional.
/// </param>
/// <returns>
/// The current value of datacontract parameter fromDate
/// </returns>
[DataMemberAttribute('From date')]
public TransDate parmFromDate(TransDate _fromDate = fromDate)
{
fromDate = _fromDate;
return fromDate;
}
/// <summary>
/// Gets or sets the value of the datacontract parameter RecordId.
/// </summary>
/// <param name="_toDate">
/// The new value of the datacontract parameter toDate; optional.
/// </param>
/// <returns>
/// The current value of datacontract parameter toDate
/// </returns>
[DataMemberAttribute('To date')]
public TransDate parmToDate(TransDate _toDate = toDate)
{
toDate = _toDate;
return toDate;
}
/// <summary>
/// Gets or sets the value of the datacontract parameter In-house bank.
/// </summary>
/// <param name="_vendAccount">
/// The new value of the datacontract parameter assetID; optional.
/// </param>
/// <returns>
/// The current value of datacontract parameter assetID
/// </returns>
[DataMemberAttribute('AssetID')]
public EntAssetObjectID parmAssetID(EntAssetObjectID _assetID = assetID)
{
assetID = _assetID;
return assetID;
}
}
=====================================================================
Step 2 :- Create a DP Class
[
SRSReportParameterAttribute(classStr(AvaEntAssetChecklistReportContract))
]
class AvaEntAssetChecklistReportDP extends SRSReportDataProviderBase
{
AvaEntAssetChecklistTmp assetChecklistTmp;
AvaEntAssetChecklistReportContract assetChecklistDetailContract;
[SRSReportDataSetAttribute(tableStr(AvaEntAssetChecklistTmp))]
public AvaEntAssetChecklistTmp getAvaEntAssetChecklistTmp()
{
select assetChecklistTmp;
return assetChecklistTmp;
}
public void processReport()
{
AvaEntAssetChecklistDetailView entAssetChecklistView;
TransDate fromDate;
TransDate toDate;
EntAssetObjectID assetID;
RecordInsertList checkListDetailToBeInserted = new RecordInsertList(tableNum(AvaEntAssetChecklistTmp),
true, // skip insert
true, // skip database log
true, // skip events
true, // skip aos validation
false, // skip RLS validation
assetChecklistTmp);
assetChecklistDetailContract = this.parmDataContract() as AvaEntAssetChecklistReportContract;
fromDate = assetChecklistDetailContract.parmFromDate();
toDate = assetChecklistDetailContract.parmToDate();
assetID = assetChecklistDetailContract.parmAssetID();
while select entAssetChecklistView
where entAssetChecklistView.ObjectID == assetID
&& entAssetChecklistView.RegisteredDateTime >= DateTimeUtil::newDateTime(fromDate, 0)
&& entAssetChecklistView.RegisteredDateTime <= DateTimeUtil::newDateTime(toDate, 86399)
if(entAssetChecklistView)
{
assetChecklistTmp.ObjectID = assetID;
assetChecklistTmp.ChecklistName = entAssetChecklistView.ChecklistName;
assetChecklistTmp.ChecklistValue = entAssetChecklistView.ChecklistValue;
assetChecklistTmp.RegisteredDateTime = entAssetChecklistView.RegisteredDateTime;
assetChecklistTmp.CreatedWorkerName = entAssetChecklistView.CreatedWorkerName;
assetChecklistTmp.WorkOrderId = entAssetChecklistView.WorkOrderId;
checkListDetailToBeInserted.add(assetChecklistTmp);
}
checkListDetailToBeInserted.insertDatabase();
}
}
=====================================================================
Comments
Post a Comment