Monday 16 December 2013

DP Class for SSRS Reports in ax 2012

DP Class
[
SRSReportQueryAttribute(querystr(ICDOCCollectorInformation)),
SRSReportParameterAttribute(classstr(ICDOCCollectorInformationContract))
]
public class ICDOCCollectorInformationDP extends SRSReportDataProviderBase
{
// AssetSumCalc assetSumCalc;
TransDate fromDate;
TransDate toDate;
ICDOCCollectorInformationTmp ICDOCCollectorInformationTmp;
CollectorInformation CollectorInformation;
CollectorInformationLine CollectorInformationLine;
Name dimension;
AgentCode agentCode;
Branch branch;
}
______________________________________________________________________
private Query buildQuery(
Query _query,
fromDate _fromDate,
ToDate _toDate,
AgentCode _agentCode,
Branch _branch)
{

if(_fromDate && _toDate)
_query.dataSourceTable(tablenum(CollectorInformationLine), 1).addRange(fieldnum(CollectorInformationLine, FromDate)).value(queryRange(_fromDate,_toDate));

if(_agentCode)
_query.dataSourceTable(tablenum(CollectorInformation), 1).addRange(fieldnum(CollectorInformation, AgentCode)).value(queryvalue(_agentCode));

if(_branch)
_query.dataSourceTable(tablenum(CollectorInformation), 1).addRange(fieldnum(CollectorInformation, Branch)).value(queryvalue(_branch));

return _query;
}
______________________________________________________________________
[
SRSReportDataSetAttribute(tablestr(ICDOCCollectorInformationTmp))
]
public ICDOCCollectorInformationTmp getICDOCCollectorInformationTmp()
{
select ICDOCCollectorInformationTmp;
return ICDOCCollectorInformationTmp;
}
______________________________________________________________________
public void getReportParameters()
{
ICDOCCollectorInformationContract datacontract = new ICDOCCollectorInformationContract();
ICDOCCollectorInformationContract ICDOCCollectorInformationContract = this.parmDataContract();

if(ICDOCCollectorInformationContract)
{
fromDate = ICDOCCollectorInformationContract.parmFromDate();
toDate = ICDOCCollectorInformationContract.parmToDate();
agentCode= ICDOCCollectorInformationContract.parmAgentCode();
branch = ICDOCCollectorInformationContract.parmBranch();
}
}
_____________________________________________________________________
private void insertICDOCCollectorInformationTmp()
{
PICDOCCollectorInformationTmp.AgentCode = CollectorInformation.AgentCode;
ICDOCCollectorInformationTmp.Employee = CollectorInformation.Employee;
ICDOCCollectorInformationTmp.Name = CollectorInformation.CollectorName();
ICDOCCollectorInformationTmp.Branch = CollectorInformation.Branch;
ICDOCCollectorInformationTmp.FromDate = CollectorInformationLine.FromDate;
ICDOCCollectorInformationTmp.ToDate = CollectorInformationLine.ToDate;
ICDOCCollectorInformationTmp.TargetAmount = CollectorInformationLine.TargetAmount;
ICDOCCollectorInformationTmp.AchievedAmount = CollectorInformationLine.AchievedAmount;
ICDOCCollectorInformationTmp.City = CollectorInformationLine.City;
ICDOCCollectorInformationTmp.insert();
}
____________________________________________________________________
[SysEntryPointAttribute]
public void processReport()
{
Query query ;
QueryRun queryRun;
QueryBuildDataSource qbds;
this.getReportParameters();
queryRun=new QueryRun(this.buildQuery(this.parmQuery(),fromDate,toDate,agentCode,branch));
while(queryRun.next())
{
CollectorInformation = queryRun.get(tablenum(CollectorInformation));
CollectorInformationLine = queryRun.get(tablenum(CollectorInformationLine));
this.insertICDOCCollectorInformationTmp();
}
}

No comments:

Post a Comment